| Author |
need help on synchronized
|
Mike Liu
Greenhorn
Joined: Jan 24, 2002
Posts: 3
|
|
Hi, can some one explain the difference between the following methods? public void push(char c){ synchronized(this){ \\code } } public synchronized push(char c){ \\code } thanks for helping me out
|
 |
Rajinder Yadav
Ranch Hand
Joined: Jan 18, 2002
Posts: 178
|
|
if it's not obvious, one sync's on the current object in a code block and the other sync's on the current object during the entire execution of the method. The first is a more fine-grain way to perform sync's on shared resources.
|
<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
|
 |
 |
|
|
subject: need help on synchronized
|
|
|