0

I have an application that has bunch of threads(around 5) making calls to a Network resource. I have a future for all threads and if one of thread returns the result I am fine. Is there an efficient way of doing this in java. Right now I am doing

for(future : futureList) {   
   future.get().    // This is blocking. 
}

I am looking for a way of getting the results of each future as soon as its done.

Naruto
  • 4,221
  • 1
  • 21
  • 32
mousey
  • 11,601
  • 16
  • 52
  • 59

1 Answers1

0

Look at CompletableFuture.thanAccept()

Konstantin Labun
  • 3,688
  • 24
  • 24