package J20250730;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo11_DeadLock
 * @description
 * @create 2025/7/30
 */
public class Demo11_DeadLock {
    public static void main(String[] args) {
        Object o1=new Object();
        Object o2=new Object();

        new Thread(()->{
            while (true){
                synchronized (o1){
                    synchronized (o2){
                        System.out.println("线程1........");
                    }
                }
            }
        },"线程1").start();
        new Thread(()->{
            while (true){
                synchronized (o2){
                    synchronized (o1){
                        System.out.println("线程2........");
                    }
                }
            }
        },"线程2").start();
    }
}
