le programme suivant donne le résultat suivant
End of main Thread 1
From Thread 1 i=1
From Thread 1 i=2
From Thread 1 i=3
From Thread 1 i=4
From Thread 1 i=5
End of main Thread 3
From Thread 3 j=1
From Thread 3 j=2
From Thread 3 j=3
From Thread 3 j=4
From Thread 3 j=5
mon question est :
pourquoi la ligne "End of main Thread 1" et la ligne "End of main Thread 3"
apparaît pas après la ligne "From Thread 1" et "From Thread 3 j=5 "
voilà mon programme
merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 class multi1 extends Thread { public void start() { for(int i=1;i<=5;i++) { System.out.println("\tFrom Thread 1 i="+i); } } }; class multi3 implements Runnable { public void run() { for(int j=1;j<=5;j++) { System.out.println("\tFrom Thread 3 j="+j); } } }; public class RunThread { public static void main(String[]args) { multi1 m1=new multi1(); m1.start(); System.out.println("End of main Thread 1"); multi3 m3=new multi3(); Thread threadmulti3=new Thread(m3); threadmulti3.start(); System.out.println("End of main Thread 3"); } }
Partager