public class DeadLockTest {
private static String A = "A";
private static String B = "b";
public static void main(String[] args) {
DeadLockMethod();
}
public static void DeadLockMethod(){
Thread t1 = new Thread(new Runnable() {
public void run() {
synchronized (A){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (B){
System.out.println("线程A");
}
}
}
});
Thread t2 = new Thread(new Runnable() {
public void run() {
synchronized (B){
synchronized (A){
System.out.println("Thread B");
}
}
}
});
t1.start();
t2.start();
}
}