• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to acquire a lock on object.  RSS feed

 
karunakar rao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is an interview question ,could anybody help,how to acquire a lock on particular object of class, what is the use of it.
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by karunakar rao:
this is an interview question ,could anybody help,how to acquire a lock on particular object of class, what is the use of it.

hey,
The lock of an object, which is grabbed when you have a thread running in, particular a synchronized thread. once a thread has the lock no other object can touch the object. This thread will get the lock of an object and not let it go until the thread has finished what it has to do, then give the objects lock up, so that other threads can use the object.
All objects have a lock.
Hope this helps.
Davy
[ March 03, 2004: Message edited by: Davy Kelly ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!