死锁的代码要会写,只有会写死锁的代码,以后才会注意避免产生死锁的问题。
测试代码:
public class Test01 {
public static void main(String[] args) {
Object o1 = new Object();
Object o2 = new Object();
MyThread1 t1 = new MyThread1(o1, o2);
MyThread2 t2 = new MyThread2(o1, o2);
t1.setName(