public class ThreadDemo19 {
private static Object o1 = new Object();
private static Object o2 = new Object();
public static void main(String[] args) {
Thread t1 = new Thread(){
public void run(){
synchronized (o1){
System.out.println(getName() + "====o1");
synchronized (o2){
System.out.println(getName() + "====o2");
}
}
}
};
Thread t2 = new Thread(){
public void run(){
synchronized (o2){
System.out.println(getName() + "====o2");
synchronized (o1){
System.out.println(getName() + "====o1");
}
}
}
};
}
}
标签:synchronized,getName,System,死锁,多线程,o2,o1,out From: https://www.cnblogs.com/xbyss/p/17663044.html