直接把运行结束的语句删掉不妥。
public synchronized void method() {
print(tName() + "开始执行");
try {
Thread.sleep(3000);
if (tName().equals("Thread-0")) {
throw new RuntimeException();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
print(tName() + "执行结束");
}
public synchronized void method() {
print(tName() + "开始执行");
try {
Thread.sleep(3000);
if (tName().equals("Thread-0")) {
throw new RuntimeException();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
print(tName() + "执行结束");
}
2019-01-30