How it works...

In this recipe, you implemented a test for the LinkedTransferQueue class using the MultithreadedTC library. You can implement a test in any concurrent application or class using this library and its metronome. In the example, you implemented the classical producer/consumer problem with two consumers and a producer. You wanted to test that the first String object introduced in the buffer is consumed by the first consumer that arrives at the buffer, and the second String object introduced in the buffer is consumed by the second consumer that arrives at the buffer.

The MultithreadedTC library is based on the JUnit library, which is the most often used library to implement unit tests in Java. To implement a basic test using the ...

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.