:confused:If there exists a class lock and from this class different thread objects or different objects & there corresponding threads are created, may they run simultaneously?:?:
e.g.

public class Smiley extends Thread {
 
               public void run() {
                while(true) {
                 try { synchronized(Smiley.class) {
                  System.out.print(":");
                  sleep(100);
                  System.out.print("-");
                  sleep(100);
                  System.out.print(")");
                  sleep(100); }
                 } catch (InterruptedException e) {
                  e.printStackTrace();
                 }
                }
               }

                public static void main() {
                new Smiley().start();
                new Smiley().start();
               }
              }

here in spite of instanciation of two separate thread objects (i.e. these are not common shared resource), is it due to having the common class lock which is preventing the other thread at synchronization?:icon_exclaim:
:icon_idea:With or without static methods, at the time of running, how much tasks are performed during class loading and what are left for the instances or objects? How these are related? Do they all happen at runtime? For which the JDK and JVM become liable? ......... :X

This article has been dead for over six months. Start a new discussion instead.