I saw somebody's lock code here like this:
private Set set = Collections.synchronizedSet(new HashSet());
if(record == -1){
for(int i = 1; i<=recordCount; i++)
lock(i);
}else{
synchronized(set){
while( (set.contains(new Integer(record))) ){try{
set.wait();
}catch(InterruptedException e){}
}
set.add(new Integer(record));
//
}
}
I think the set.notifyAll() should be added to the comment to wake up other threads which are waiting on the set object, while the current
thread can do something else. Am I missing anything here? Please.