des Thread dans un boucle FOR
bonsoir
j'ai dans la fonction main :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| long t1=System.currentTimeMillis();
for(int i=0; i<1000;i++)
{
i=i+1;
TestThread t= new TestThread(i);
t.start();
/*
if(i==999)
{
t.join();
}
*/
}
// TODO Auto-generated method stub
long t2=System.currentTimeMillis()-t1;
System.out.println("temps d'execution T2 thread ===="+t2); |
TestThread avec ce code la
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| public class TestThread extends Thread {
int i;
public TestThread(int i)
{
this.i=i;
}
public void run()
{
System.out.println("i==" +i);
}
} |
SVP, J’ai une question comment je peux attendre tous les Thread, créent dans le boucle For, se terminent et puis je passe a l'affichage de temps d'exécution t2
merci de me répondre