| Author |
a question about somebody's lock code
|
michael opto
Greenhorn
Joined: Jan 17, 2002
Posts: 29
|
|
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.
|
 |
michael opto
Greenhorn
Joined: Jan 17, 2002
Posts: 29
|
|
|
Forget about it. I see now. I was thinking about something else. Sorry, please delete this post.
|
 |
 |
|
|
subject: a question about somebody's lock code
|
|
|