Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronization

 
Sundeep Gupta
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


Does a thread releases lock on all the objects when it calls wait() on an object, or only the lock of that specific object is released.

I think other object's lock will be held with thread.

Tell me whether i'm right or wrong


Thanks,
Sundeep
 
Henry Wong
author
Marshal
Pie
Posts: 21380
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wait() will only release the lock on the object that you are waiting on.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic