Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda