i coundn't understand an simple question,
what does a synchronized method use as a mutex in java-
a) A globally declared mutex
b) A method's mutex
c) A owning object's(this's) mutex
can anybody elaborate this? thanks in advance
i coundn't understand an simple question,
what does a synchronized method use as a mutex in java-
a) A globally declared mutex
b) A method's mutex
c) A owning object's(this's) mutex
can anybody elaborate this? thanks in advance
 
    
    It’s option c); from Goetz et al. (2006), Java Concurrency in Practice:
A
synchronizedmethod is a shorthand for asynchronizedblock that spans an entire method body, and whose lock is the object on which the method is being invoked. (Staticsynchronizedmethods use theClassobject for the lock.)
