Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how thread can aquire more than one lock

 
Shashank Sharma
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic