This week's book giveaway is in the Performance forum. We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line! See this thread for details.
Below test can throughtly check blocking ability of database .lock() method. This feature is one of the most important MUSTS in OCMJD assignment, and it's commonly overlooked by standard tests. This code locks random records, and then creates additional threads, to check two things:
- if .lock() method blocks other threads for locking same record
- if record is not locked, it can be always locked with no problems
If code deadlocks, its simple mean that .lock() method erroneously blocked, when record is not locked by other thread.