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,111
  • 1
  • 20
  • 31
mousey
  • 11,173
  • 15
  • 50
  • 56

1 Answers1

0

Look at CompletableFuture.thanAccept()

Konstantin Labun
  • 3,428
  • 23
  • 24