Hi,
I am currently preparing for
SCJP. I have a doubt in
Thread Chapter.
Could some one please explain the following paragraph that I have taken from SCJP 5 by Kathy Sierra and Bert.
Page Nos: 708 and 709
Page No 708 bottom:
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
Page No 709 top
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. In the above sentences when they say
third-party object, do they mean a object of a different class or a different object of the same class in which the synchronized block exits.
Also please explain this line......
That gives you the ability to have more than one lock for code synchronization within a single object.[/I]
..Nothing understood from this line. Please explain..
Thanks and Regards
Loga
[ November 05, 2008: Message edited by: Loganathan Karunakaran ]
[ November 05, 2008: Message edited by: Loganathan Karunakaran ]
[ November 05, 2008: Message edited by: Loganathan Karunakaran ]
[ November 05, 2008: Message edited by: Loganathan Karunakaran ]