private HashMap locks;
How about private
final HashMap locks, for clarity?
public synchronized void lock(RemoteData client,int recordNum) {
Since no operation is performed on client, except for adding it to the collection, a more formal declaration looks better (program to interface/superclass, not to implementation):
public synchronized void lock(Object client,int recordNum)
if (locks!=null) {
The collection object should never be null, so there is no reason to check for it every time. Instantiate it in the constructor.
databaseLock=new Integer(LockManager.DATABASE_LOCK)
Your databaseLock integer is constant, and therefore should be declared as private static final, and created just once.
if (locks!=null && locks.size()>0) {
No reason to check the size, either.
if (locks.containsKey(recordNumber) ) {
RemoteData owner=(RemoteData)locks.get(recordNumber)
if (owner==client) {
How about 1 line instead of 3:
if (locks.get(recordNumber) == client)
Eugene.
[ April 01, 2003: Message edited by: Eugene Kononov ]