Skip to content

Commit a179863

Browse files
committed
Doesn't need CopyOnWrite
1 parent fed9a09 commit a179863

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

lowlevel/DelayQueueDemo.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DelayedTask implements Runnable, Delayed {
1313
private final int delta;
1414
private final long trigger;
1515
protected static List<DelayedTask> sequence =
16-
new CopyOnWriteArrayList<>();
16+
new ArrayList<>();
1717
public DelayedTask(int delayInMilliseconds) {
1818
delta = delayInMilliseconds;
1919
trigger = System.nanoTime() +
@@ -49,7 +49,7 @@ public static class EndTask extends DelayedTask {
4949
@Override
5050
public void run() {
5151
sequence.forEach(dt ->
52-
System.out.println(dt.summary() + " "));
52+
System.out.println(dt.summary()));
5353
}
5454
}
5555
}
@@ -58,8 +58,7 @@ public class DelayQueueDemo {
5858
public static void
5959
main(String[] args) throws Exception {
6060
DelayQueue<DelayedTask> tasks =
61-
Stream.concat(
62-
// Tasks with random delays:
61+
Stream.concat( // Random delays:
6362
new Random(47).ints(20, 0, 4000)
6463
.mapToObj(DelayedTask::new),
6564
// Add the summarizing task:

0 commit comments

Comments
 (0)