|
|
|
|
Bonjour,
J'ai un petit soucis avec javax.
J'ai un programme comme ca :
for (i=0;i<NUMBER_OF_STEPS;i++)
{
natStep(1) ;
refreshControl();
}
Ca ne fonctionne toujours pas ...
|
Ce n'est pas possible qu'il te fasse tout les machin nat en premier, puis ensuite tout les refresh, il faut que tu jette un oeil au fonctionnement de ta fonction natStep, elle doit fair'e un truc bien louche dans son code.
~ iclic @ gauch,iclic, iclic @ droate, iclic, iclic
|
Avec des thread cela donne ca :
stepThread NST = new stepThread() ;
for (i=0;i<NUMBER_OF_STEPS;i++)
{
refreshControl() ;
NST.start() ;
try{
NST.join(10) ;
}
catch (InterruptedException ie) {}
}//End of for
}
mon thread step : class stepThread extends Thread
{
stepThread(){}
public void run()
{
natStep(1) ;
}
}
pour NUMBER_OF_STEP = 1 ca marche, ( normal :p ) Mais lorsque j'ai NUMBER_OF_STEP > 1 il me leve une exception du type : AWT-EventQueue-0" java.lang.IllegalThreadStateException une idée ? |
C'est ton
class refresh extends Thread
{
private int nbTour;
refresh( int nbTour ){
this.nbTour = nbTour;
}
public void run()
{
for(int i=0;i<nbTour;i++) {
refreshControl() ;
try {
sleep(100);
}
catch( Exception e ){ ; }
}
}
}
class natStep extends Thread
{
private int nbTour;
natStep( int nbTour ){
this.nbTour = nbTour;
}
public void run()
{
for(int i=0;i<nbTour;i++) {
natStep(1) ;
try {
sleep(100);
}
catch( Exception e ){ ; }
}
}
}
Et pour ton principal :
netStep n = new netStep(NUMBER_OF_STEPS);
refresh r = nes refresh(NUMBER_OF_STEPS);
n.start();
r.start();
n.join();
r.join();
Essay ca pour voir.. ~ iclic @ gauch,iclic, iclic @ droate, iclic, iclic et ya pas de bôg môsieu ! ~ |
Répondre à Jeremy
|