2016-12-21 11:06:49 -08:00
|
|
|
// concurrent/NapTask.java
|
2021-01-31 15:42:31 -07:00
|
|
|
// (c)2021 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
|
|
|
|
2016-12-21 11:06:49 -08:00
|
|
|
public class NapTask implements Runnable {
|
2016-07-05 14:46:09 -06:00
|
|
|
final int id;
|
2016-12-21 11:06:49 -08:00
|
|
|
public NapTask(int id) { this.id = id; }
|
2021-01-31 15:42:31 -07:00
|
|
|
@Override public void run() {
|
2017-01-22 16:48:11 -08:00
|
|
|
new Nap(0.1); // Seconds
|
2016-07-05 14:46:09 -06:00
|
|
|
System.out.println(this + " " +
|
|
|
|
Thread.currentThread().getName());
|
|
|
|
}
|
2021-01-31 15:42:31 -07:00
|
|
|
@Override public String toString() {
|
2016-12-21 11:06:49 -08:00
|
|
|
return "NapTask[" + id + "]";
|
2016-07-05 14:46:09 -06:00
|
|
|
}
|
|
|
|
}
|