20.6 Timer (Java book) - can use DelayQueue/CHM

#1

Hi guys:

When doing 20.6 I used Java’s DelayQueue and ConcurrentHashMap. This simplifies the solution quite a bit as the DelayQueue is made for this use case and DQ and CHM are both thread safe.

Example: https://gist.github.com/sourcedelica/adf75682e937e20daa50

An interesting alternative to this approach is the Timing Wheel.

0 Likes