How can I ensure that the Get method of a FutureTask will only be called when all threads have already executed?
I have this method:
for (int j = 0; j < threadNum; j++) {
FutureTask<Integer> futureTask = taskList.get(j);
if(!taskList.get(j).isDone()){
System.out.println("Não terminou: ");
}
amount += futureTask.get();
}
Should I make an infinite loop before this is to ensure that it will only arrive here when all threads finish running or is there another way to do this?