|
|
|
|
|
by dragontamer
1814 days ago
|
|
That's Java's Object.lock() mechanism. All variables inside of an object (aka: any class) are assumed to be related to each other. synchronized(foobar_object){ baz(); } ensures that all uses of foobar_object inside the synchronization{} area are sequential (and therefore correct). -------- The issue is that some people (a minority) are interested in "beating locks" and making something even more efficient. |
|
The only time synchronized(explicit_object) relates to anything else is when also using the keyword where `synchronized void foo()` is equivalent (with a minor performance difference) to `synchronized(this) { ... }` wrapping the entire body of the foo method.