No, this is not entirely correct. Vector synchronized over the Vector instance itself, while the synchronized block is actually synchronized in the instance that contains Vector . The two methods for entering a synchronized block should first get the monitor associated with this , and then get the monitor associated with the Vector instance.
The case with the edge is that if one of the threads contains a monitor that the other requires (if you have other synchronized blocks), you may have a dead end.
However, given only the section of the code sent, the thread that the monitor first receives on this will be the first to perform the operation on the vector. In addition, the sequence of operations in a Vector instance can be performed by the first thread without any sequence of operations by the second thread; this is necessary if you want to perform an atomic sequence of operations with a Vector instance, which will not be the case in a regular synchronized Vector instance. To present this in pseudo-code, the sequence of operations in the two cases presented below will be different if the context switches between two or more threads executing the same block:
Case A
synchronized { vector.add(a); vector.add(b); }
Case B
{ vector.add(a); vector.add(b); }
source share