Hello!
Tell me how to solve this problem: Is there a class in which there is a field - List <? extends Thread> , as a function waitFor () to write, so that when entering it from the current thread, he waited until all the threads from the list were executed.

    1 answer 1

    I thought to do this thing:

    for(MyExtendedThread th: ListOfThreads){ th.join(); } 
    • one
      I don't really shave my PC for Java, but try using the CountDownLatch or Future classes. - Helisia
    • something like this: ExecutorService executorService = Executors.newFixedThreadPool (ListOfThreads.size ()); executorService.invokeAll (ListOfThreads); - jmu pm
    • @jmu, this is only if we can run the threads ourselves. And in this case, the @voipp option is quite suitable. - Nofate
    • @Nofate I had a doubt that since the iteration is thread-protected, an exception will be thrown. but it seems to be working - voipp