The syntax of a synchronized block is
synchronized (object) {
<code>
}
As far as I could understand, two different threads will compete - even if cooperating - on the use of
<code>. What about the
object? I think that it is some sort of reference to the monitor and that two synchronized blocks with the same
object must be understood as the same monitor but is it "
synchronized" too? In other words, what happens to code outside the monitor if it references the
object?
Thanks,
Ricardo