Comment faire pour exécuter des tâches dans ExecutorService séquentiellement?

J'ai trois fils qui sont reliés, c'est à dire le deuxième thread s'exécute après le premier meurt.

C'est le code que j'ai:

public class Main {
    public static void main(String args[]) throws Exception {
        final Thread thrdA = new Thread(() -> System.out.println("Message 1"));
        final Thread thrdB = new Thread(() -> System.out.println("Message 2"));
        final Thread thrdC = new Thread(() -> System.out.println("Message 3"));

        thrdA.start();
        thrdA.join();
        thrdB.start();
        thrdB.join();
        thrdC.start();
        thrdC.join();

    }
}

Comment mettre en œuvre cette fonctionnalité à l'aide ExecutorService au lieu de trois thread objets?

OriginalL'auteur Raees Sharif-Aamir | 2015-08-16