A synchronized method acquires a lock on the whole object that has the method. Think about two synchronized methods A & B and two threads 1 & 2. If
thread 1 enters method A, then thread 2 cannot enter method A or B until thread 1 exits A. That makes sense if both methods modify multiple variables in the object, but may be overkill for simple methods.
When you synchronize a block on some other object you can pick what you synchronize on and how long. I have an object where some methods sync on a counter and some methods sync on a message. I figured out that it's ok for one thread to modify the counter while another modifies the message, but I can't let two threads modify the counter or two threads modify the message.
We had another discussion about how to chose between sync on method and sync a block on an object. Most people preferred to keep the scope of the sync block as small as possible (and no smaller, of course) but I don't think we agreed on better rules to help you decide.
Here's a promising looking article on synchronizing:
How the JVM Performs Thread Synchronization. Hope that helps!
[ October 28, 2004: Message edited by: Stan James ]