JAVA JUC synchronized 锁的理解

synchronized 锁,对于非静态方法,默认为this,对于静态方法,默认为 该类的运行时类实例.

 

 

 

class Number  {
    public synchronized void getOne(){
        System.out.println("one");
    }
    public synchronized void getTwo(){
        System.out.println("two");
    }
    public void getThree(){
        System.out.println("three");
    }

}

 

posted @ 2020-03-14 10:17  超级学渣渣  阅读(235)  评论(0编辑  收藏  举报