Java is an OO language which means you have Objects and they interact with each other to form a complete program. Each Object is associated with a monitor. Synchronization is essentially done over the objects which actually get a lock on the objects monitor.
Now coming to your question. When you say
synchronize (Test.class) {
...
}
lock is obtained over the Test.class object. Also for a fully qualified class name JVM will make sure it is loaded only once per class loader (unless it is GCed). So you will always have only one instance of Test.class
per JVM instance (Considering class loading is done by same class loaded). By JVM instance I mean a Java process which will have it's own PID. If one thread have lock over Test.class
no other thread can get this lock unless it is released by the holding thread (Same thread can get the lock again - Locks in Java are Reentrant nature).
If you start new java process -> new JVM instance -> new instance of Test.class
is loaded by class loader -> It's lock can be obtained and is not dependent on any other JVM instance running.
Note : If Class objects are separate ( same class loaded by different class loaders for instance - like what happens in case of web apps ) then you can certainly get separate lock on each. You will not be able to cast an instance of one class to the other.