public static void main(String[] args) throws InterruptedException {
        //两个线程交叉打印1-100
        //
        //1执行 唤醒2  1等待   2执行 唤醒1  2等待
        AtomicInteger a= new AtomicInteger(1);
        Object lock = new Object();

        Thread thread0 = new Thread(() -> {
            //到 100  zhongzhi
            //thread1
            synchronized (lock){
                while (a.get()<=100){
                    System.out.println(a.getAndIncrement()+Thread.currentThread().getName());
                    lock.notifyAll();
                    try {
                        if (a.get() <= 100) {
                            lock.wait();
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        },"Thread-01");


        Thread thread1 = new Thread(() -> {
            synchronized (lock){
                //thread2
                //到 100  zhongzhi
                while(a.get()<=100){
                    System.out.println(a.getAndIncrement()+Thread.currentThread().getName());
                    lock.notifyAll();
                    try {
                        if (a.get() <= 100) {
                            lock.wait();
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        },"Thread-02");


        thread0.start();
        thread1.start();


    }

public class Demosingleton {
    //懒汉
    private static volatile Demosingleton demosingleton;

    public Demosingleton() {
    }
    //双锁
    public static Demosingleton getDemosingleton() {
        if(demosingleton != null){
            synchronized (Demosingleton.class){
                if (demosingleton != null){
                    demosingleton=new Demosingleton();
                }
            }
        }
        return demosingleton;
    }

}

刚学java菜鸡,永劫无间蚀月,王者荣耀王者,金铲铲小铂金,第五人格菜鸡,原神开服玩家,星穹铁道菜鸡,崩坏的菜鸡,闪耀暖暖,和平精英,LOL,CSGO,以及三A大作收集者等等。。。