• Post Reply Bookmark Topic Watch Topic
  • New Topic

Owner of an object's monitor  RSS feed

 
Roger Zhao
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all
Given:
A Thread can become the owner of an object's monitor by which two of the following?
a. By invoking the sleep method on the Thread.
b. By blocking on IO.
c. By entering a synchronized instance method of the Object.
d. By invoking the wait method on the Object.
e. By entering the body of a block that is synchronized on the Object.
f. By entering a synchronized static method of the Object.
g. By invoking the notify method on the Object.
h. None of the above.
c,e is right answer.

Static methods are synchronized on the Class object of the class. Instance methods are synchronized on the instance of the class.

Pls see option f. By entering a synchronized static method of the Object, will thread become the owner of the object's monitor?
The object in the question is not the class object but the instance of the class?
I am really confused , help!
Thanks in advanced.
Roger
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By entering a synchronized static method of the Object , the thread becomes the owner of the class monitor and not object monitor.
This is b'caz static methods not specific to instances
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!