Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
How do I set result of java.util.concurrent.Future?

The Future interface doesn't provide a method for setting the result. In the docs, they say,

A Future represents the result of an asynchronous computation. Methods are provided to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation.

But I don't understand how do I set the result in the first place?

I was comparing Future to DeferredResult from Spring and they both basically represent the result of Async computation but DeferredResult has method for setting the result and Future doesn't?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you don't want to create your own class implementing Future and providing a setter (or extending FutureTask and making the setter public), you can use the ready-made CompletableFuture. It allows you to set the values, as well as a lot of other tricks that the Future interface doesn't show.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!