Exactly - most books and documentation about resource exclusion about this make it abundantly clear that synchronized methods shouldn't call each other for this very reason.

Thanks for adding that point.

phil.

Oliver Zeigermann wrote:
On Thu, 10 Feb 2005 13:09:14 -0500, WHIRLYCOTT <[EMAIL PROTECTED]> wrote:

2) synchronize on the containing object's monitor:

       ...
       public synchronized whatever(Object arg1) {...}
       public synchronized something() {...}
       ...



Blindly doing this can easily lead to deadlocks. Consider thread #1 in
method whatever accesses another synchronized object and needs to wait
for thread #2 to release the lock on it. Now thread #2 tries to access
method something and - of course - needs to wait for thread #1 to
release the lock on that first objec. Now both threads mutually wait
for each other and you have a deadlock.

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- Whirlycott Philip Jacob [EMAIL PROTECTED] http://www.whirlycott.com/phil/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to