February 2014
Beginner
1248 pages
62h 25m
English
[Note: This section is intended for advanced programmers who want to control synchronization.2] The previous example showed how multiple threads can share a single-element buffer in a thread-safe manner by using the ArrayBlockingQueue class that encapsulates the synchronization necessary to protect the shared mutable data. For educational purposes, we now explain how you can implement a shared buffer yourself using the synchronized keyword and methods of class Object. Using an ArrayBlockingQueue generally results in more-maintainable, better-performing code.
After identifying the shared mutable data and the synchronization policy (i.e., associating ...
Read now
Unlock full access