PriorityBlockingQueue is unbounded, but I need to bound it somehow. What is the best way to achieve that?
For information, the bounded PriorityBlo
Not a single answer so far has all of the following properties:
BlockingQueue interface.Unfortunately, there is no BlockingQueue implementation in the standard Java library. You will either need to find an implementation or implement something yourself. Implementing a BlockingQueue will require some knowledge on proper locking.
Here's what I suggest: Have a look at https://gist.github.com/JensRantil/30f812dd237039257a3d and use it as a template to implement your own wrapper around a SortedSet. Basically, all the locking is there and there are multiple unit tests (that will need some tweaking).