wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how thread can aquire more than one lock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how thread can aquire more than one lock " Watch "how thread can aquire more than one lock " New topic
Author

how thread can aquire more than one lock

Shashank Sharma
Ranch Hand

Joined: Sep 27, 2006
Posts: 91
thread can enter a synchronized method, thus acquiring a lock, and then immediately invoke a synchronized method on a different object, thus acquiring that lock as well.

Above lines are taken from K& B page no708.

here author is talking about simultaneously obtaining a lock on " different object ",how do we re declare the same thread with a new runnable object.


please help me with this .please provide an example if any one can
thanks in advance
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
How obtain many locks:


How declare thread using Runnable:


Someone uses method with anonymous class that implements Runnable
- remember: Runnable is an interface, not a class!!!


And this also starts the Thread:

[ August 06, 2008: Message edited by: Ireneusz Kordal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how thread can aquire more than one lock