assertEquals("all 3 task is executed", 3, c.x);
}
@Test
public void singletonTasks() throws InterruptedException {
TaskRunner tk = new TaskRunner();
final Counter c = new Counter();
for (int i = 0; i < 5; i++) {
tk.submitNamed("myTask", true, new Runnable() {
@Override
public void run() {
sleep();
c.incr();
}
});
}
tk.shutdown();
tk.awaitTermination(1, TimeUnit.DAYS);
assertEquals("only one task is executed", 1, c.x);
}