• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wait() release all locks?

 
Byron Foo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one of KB mock Qs says -- The following statement is true:
When a thread is waiting as result of wait(), it release all the locks it holds.

Which is wrong according to Khalid A. Mughal's book -- "Note that the waiting thread does not relinquish any other object locks that it might hold, only that of the object on which the wait() method was invoked. "

Who is right? The thread release all or just one lock?

Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think just the object that it issues the wait in.

Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic