Fil de discussion.join() équivalent en exécuteur testamentaire

J'ai une question de newbie. J'ai ce code:

public class Main 
{

    public static void main(String[] args) throws InterruptedException 
    {
        //TODO Auto-generated method stub
        IntHolder aHolder=new IntHolder();
        aHolder.Number=0;

        IncrementorThread A= new IncrementorThread(1, aHolder);
        IncrementorThread B= new IncrementorThread(2, aHolder);
        IncrementorThread C= new IncrementorThread(3, aHolder);

        A.start();
        B.start();
        C.start();

        A.join();
        B.join();
        C.join();
        System.out.println("All threads completed...");

    }

}

Qui va attendre que tous les threads complète. Si j'utilise Executors comme ceci:

public class Main 
{

    public static void main(String[] args) 
    {
        //TODO Auto-generated method stub
        IntHolder aHolder=new IntHolder();
        aHolder.number=0;

        IncrementalRunable A= new IncrementalRunable(1, aHolder);
        IncrementalRunable B= new IncrementalRunable(2, aHolder);
        IncrementalRunable C= new IncrementalRunable(3, aHolder);

        ExecutorService exec = Executors.newFixedThreadPool(3);
        exec.execute(A);
        exec.execute(B);
        exec.execute(C);
        //Don't know what to do here

        System.out.println("All threads completed...");
    }
}

Comment puis-je suspendre le thread principal d'attendre que tous les fils de l'exécuteur testamentaire, pour finir, je.e le "Tous les threads terminé..." doit être imprimé après tous les threads ont fait leur travail?

vérifiez ceci : stackoverflow.com/questions/3269445/...
Demain a un blocage de la méthode get

OriginalL'auteur Mario Stoilov | 2013-12-10