java - Difference between synchronized -
is this
, example.this
same object?
e.g. call this
, example.class
inside synchronized
same object?
class example { public example() { synchronized(this) { // code } } } class example { public example() { synchronized(example.class) { // code } } }
no, this
use current object monitor, example.class
use example.class
monitor.
Comments
Post a Comment