In this recipe, you implemented the MyPriorityTransferQueue data structure. It's a data structure to be used in the producer/consumer problem, but its elements are ordered by priority, not by their order of arrival. As Java doesn't allow multiple inheritances, the first decision you took was in relation to the base class of the MyPriorityTransferQueue class. You extend the class to use the operations implemented in the PriorityBlockingQueue, not to implement them. You also implemented the TransferQueue interface to add the methods related to the producer/consumer. We made this choice because we think it is easier to implement the methods of the TransferQueue interface than the methods implemented in the PriorityBlockingQueue ...
How it works...
Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.