2016-12-07 10:34:41 -08:00
|
|
|
// lowlevel/QuittableTask.java
|
2016-12-30 17:23:13 -08:00
|
|
|
// (c)2017 MindView LLC: see Copyright.txt
|
2016-07-05 14:46:09 -06:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2016-12-21 11:06:49 -08:00
|
|
|
import onjava.Nap;
|
2016-07-05 14:46:09 -06:00
|
|
|
|
|
|
|
public class QuittableTask implements Runnable {
|
|
|
|
private boolean running = true;
|
|
|
|
public void quit() { running = false; }
|
|
|
|
public boolean running() { return running; }
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
while(running)
|
2016-12-21 11:06:49 -08:00
|
|
|
new Nap(100);
|
2016-07-05 14:46:09 -06:00
|
|
|
}
|
|
|
|
}
|