P
ppp
Hello, I have a little problem. I'm wondering how to interrupt my
thread work.
I have a several threads, they work on the same synchronized stock.
there is my pseudo-code of run method.
public void run() {
while (true) {
synchronized(Stock) {
if (Condition1)
// do something
else if (Condition2)
// do something else
else // default Condition
//i wish to end my Thread here
interrupt(); // thos method don't work
System.exit(1); // only this, but this is not good
solution...
}
try { sleep(new Random().nextInt(1000)); }
catch (InterruptedException e) {}
}
}
I wish to create 10-15 threads, and after default Condition stop.
maybe you have some good solutions of my problem?
thread work.
I have a several threads, they work on the same synchronized stock.
there is my pseudo-code of run method.
public void run() {
while (true) {
synchronized(Stock) {
if (Condition1)
// do something
else if (Condition2)
// do something else
else // default Condition
//i wish to end my Thread here
interrupt(); // thos method don't work
System.exit(1); // only this, but this is not good
solution...
}
try { sleep(new Random().nextInt(1000)); }
catch (InterruptedException e) {}
}
}
I wish to create 10-15 threads, and after default Condition stop.
maybe you have some good solutions of my problem?