We use cookies to collect and analyze information on site performance and usage,
to provide social media features and to enhance and customize content and advertisements.
public class TT extends Thread {
static final int RUN = 0;
static final int SUSPEND = 1;
static final int STOP = 2;
private int state = RUN;
public synchronized void setState(int s) {
state = s;
if (s == RUN) notify();
}
private boolean boolean checkState() {
while (state == SUSPEND) {
try {
wait();
}
catch (Exception e) {}
}
if (state == STOP)
return false;
return true;
}
public void run() {
while true {
doSomething();
if (!checkState())
break;
}
}