...
| Code Block | ||
|---|---|---|
| ||
final class ControlledStop implements Runnable {
private boolean done = false;
public void run() {
while (!isDone()) {
try {
// ...
Thread.currentThread().sleep(1000); // Do something
} catch(InterruptedException ie) {
// handle exception
}
}
}
protected synchronized boolboolean isDone() {
return done;
}
protected synchronized void shutdown() {
done = true;
}
}
|
...