19 lines
532 B
Java
Raw Permalink Normal View History

2016-12-21 11:06:49 -08:00
// concurrent/NapTask.java
// (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; }
@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());
}
@Override public String toString() {
2016-12-21 11:06:49 -08:00
return "NapTask[" + id + "]";
2016-07-05 14:46:09 -06:00
}
}