thread won't stop?
Am creating a program that is based on mixing and making perturbation in a
population containing solutions Vector so i created a for loop that stops
after a certain time given by the user. Inside the loop, am going to call
5 procedures ant i thought that if i put each procedure in a thread will
make the program making more solutions in a same time than calling normal
methods, Here i created the 5 threads, but when i start them the don't
want to stop even if i use the Thread.stop, Thread.suspend,
Thread.interrupt or Thread.destroy
Here is my code and could u help me with your ideas ?
Thread CrossOp = new Thread(new Runnable() {
public void run() {
while(true){
int rdmCross2=(int) (Math.random() * allPopulation.size()) ;
// Crossover 1st vector
int rdmCross1=(int) (Math.random() * allPopulation.size()) ;
Vector muted = new Vector();
Vector copy = copi((Vector) allPopulation.get(rdmCross2));
Vector callp = copi((Vector) allPopulation.get(rdmCross1));
muted = crossover(callp, copy);
System.out.println("cross over Between two Randoms
----------->");
affiche_resultat(muted);
allPopulation.add(muted);
}
}
});
The loop :
CrossOp.setDaemon(true);
int loop = 1;
long StartTime = System.currentTimeMillis() / 1000;
for (int i = 0; i < loop; ++i) {
CrossOp.start();
loop++;
if (timevalue < ((System.currentTimeMillis() / 1000) -
StartTime)) {
loop = 0;
}
}
CrossOp.stop();
No comments:
Post a Comment