Synchronizing a method would mean acquiring a lock to an entire method - and in the cases where synchronizing a block of code is sufficient, it might be a over-kill to synchronize an entire method. The feature for synchronizing a block code will provide the additional flexibility for limiting this process, to a code segment, instead of to an entire method.
In the morning there is hope; in the afternoon, fulfillment; in the evening, memory; at night, peace.
Yes, Ernest is right. weather you synchronize the method or a block of code inside the method but the monitor is associated with the current instance. [ February 17, 2005: Message edited by: MK Barman ]
One small difference is that, if the method is declared synchronized, then that can be seen in the Javadoc. Whereas synchronisation within the method body does not automatically appear in the Javadoc. The run-time behaviour is the same, though.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...