February 2014
Beginner
1248 pages
62h 25m
English
The simplest way to implement a bounded buffer is to use an ArrayBlockingQueue for the buffer so that all of the synchronization details are handled for you. This can be done by modifying the example from Section 23.6 to pass the desired size for the bounded buffer into the ArrayBlockingQueue constructor. Rather than repeat our previous ArrayBlockingQueue example with a different size, we instead present an example that illustrates how you can build a bounded buffer yourself. Again, using an ArrayBlockingQueue will result in moremaintainable and better-performing code. In Exercise 23.13, we ask you to reimplement this section’s example, using the Java Concurrency API techniques presented in Section 23.9 ...
Read now
Unlock full access