No, your expression does not mean what you think. The synchronized block parameter is the lock that you acquire before starting the synchronized block and releasing it at the end. In Java, everything that inherits from Object can be used as a lock (therefore no, int cannot be used as a lock).
A lock can be held only by one thread at a time, but the code inside one synchronized block can be executed simultaneously in several threads if different objects are specified as parameters. On the other hand, two threads will not be able to run different codes from different synchronized blocks if the two different synchronized blocks are assigned the same lock as a parameter.
People often use this as a lock, but they also often use an object specifically designed for locking, as OldCurmudgeon did in her answer.
source share