## synchronized获得的锁是可重入的
package cn.qqjx.thread;
import java.util.concurrent.TimeUnit;
public class MyThread {
synchronized void m1() {
System.out.println("m1 start");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
m2();
System.out.println("m1 end");
}
synchronized void m2() {
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("m2");
}
public static void main(String[] args) {
new MyThread().m1();
}
}
m1 start
m2
m1 end