Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Runnable r1 = () -> {
- System.out.println("thread 1 start");
- sleep(3000);
- System.out.println("thread 1 stop");
- };
- Runnable r2 = () -> {
- System.out.println("thread 2 start");
- sleep(3000);
- System.out.println("thread 2 stop");
- };
- Runnable r3 = () -> {
- System.out.println("thread 3 start");
- sleep(3000);
- System.out.println("thread 3 stop");
- };
- Thread t1 = new Thread(r1);
- Thread t2 = new Thread(r2);
- Thread t3 = new Thread(r3);
- t1.start();
- t2.start();
- System.out.println("--- affichage immédiat après démarrage t1 et t2 ---");
- t1.join();
- t2.join();
- System.out.println("--- je ne reprend pas tant que t1 n'est pas terminé ---");
- t3.start();
- System.out.println("--- affiché quasi au même moment que démarrage t3 ---");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement