MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

lowlevel/DelayQueueDemo.java:53–65  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

51
52public class DelayQueueDemo {
53 public static void
54 main(String[] args) throws Exception {
55 DelayQueue<DelayedTask> tasks =
56 Stream.concat( // Random delays:
57 new Random(47).ints(20, 0, 4000)
58 .mapToObj(DelayedTask::new),
59 // Add the summarizing task:
60 Stream.of(new DelayedTask.EndTask(4000)))
61 .collect(Collectors
62 .toCollection(DelayQueue::new));
63 while(tasks.size() > 0)
64 tasks.take().run();
65 }
66}
67/* Output:
68[128] Task 12 [429] Task 6 [555] Task 2 [551] Task 13

Callers

nothing calls this directly

Calls 2

runMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected