This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
All, I am looking for opinions on the way I did my locking. I have a LockManager that has a HashMap of (lock, clientId) pairs. When my RemoteData asks the LockManager to do a lock, the first thing that happens is a synchronized(hashLock) is started and it has everything in the method in this synch block. Same for my unlock block. To test my locking I put a Thread.sleep(5000) in my unlock, and it seems to be working, but I never get anything to get to the wait() line of code in the lock() method because of the syncronized(...) first line. This means that every access to modify the db is going to wait its turn even if the modifications are on different rows. Should I try to only synch after I know there is a lock on a certain row, or leave it the way I have it? It seems that my code will never hit the hashLock.wait() and that seems bad to me. Thanks.