static synchronized and non static synchronized methods in threads

后端 未结 3 1385

can any one explain the statement ...\"static synchronized method and non static synchronized method will not block each other -they can run at the same time\"

3条回答
  •  Happy的楠姐
    2020-12-09 07:07

    The lock objects are different on the static method and non-static method. The static method uses the Class object as the lock (lock obj: MyClass.class), while the non-static method uses the instance object as the lock to which the invocation of the method at that time is bound (lock obj: this).

提交回复
热议问题