O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required