img
.
Local RWLock with Local Mutex to Protect Salaries
Just for the sake of completeness, we'll consider one more design (Figure 12-10). By making the
local lock an RWlock, we can allow multiple threads to do comparisons on the same element at
the same time. If comparisons took significant amounts of time, this could be a viable design. For
our program, which does a simple string compare, this design proves to be the worst yet. It takes
up much more space, adds more complexity, and is slower by a very significant amount.
Figure 12-10. Friends/Enemies: Local Lock and RWlock
We've now completed the journey from very coarse-grained locking to very fine-grained locking
and come to the obvious conclusion. The best results are usually found in the middle, but the only
way to know is to try.
Program Design
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home