1

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

Saket Mittal
  • 3,726
  • 3
  • 29
  • 49
  • possible duplicate of [Java synchronized method lock on object, or method?](http://stackoverflow.com/questions/3047564/java-synchronized-method-lock-on-object-or-method) – Joe Jul 05 '15 at 11:44
  • no i am taking about mutex – Saket Mittal Jul 05 '15 at 12:01

1 Answers1

2

It’s option c); from Goetz et al. (2006), Java Concurrency in Practice:

A synchronized method is a shorthand for a synchronized block that spans an entire method body, and whose lock is the object on which the method is being invoked. (Static synchronized methods use the Class object for the lock.)

Chriki
  • 15,638
  • 3
  • 51
  • 66