I am reading the SCJP 5 book chapter on Threads. To quote from
the synchronization objective
"When you synchronize a method, the object used to invoke the method is the
object whose lock must be acquired. But when you synchronize a block of code, you
specify which object's lock you want to use as the lock, so you could, for example,
use some third-party object as the lock for this piece of code. That gives you the
ability to have more than one lock for code synchronization within a single object."
What does the above mean? I can't understand the part about the synhronized block
in the above paragraph
Also, is the following true
If there is a class which has a synchronized method and a synchronized block,
if a thread enters a synchronized block, no other thread can execute the synchronized
method on the same instance. Just like if a thread enters a synchronized method , no other thread
can execute any synchronized methods on the same instance
Am stuck on this part,
please help to understand
Thanks