1700449669
1700449670
}
1700449671
1700449672
private final synchronized void stop1(Throwable th){
1700449673
1700449674
/*安全检查省略*/
1700449675
1700449676
if(threadStatus!=0){
1700449677
1700449678
resume();
1700449679
1700449680
stop0(th);
1700449681
1700449682
}else{
1700449683
1700449684
if(th==null){
1700449685
1700449686
throw new NullPointerException();
1700449687
1700449688
}
1700449689
1700449690
stopBeforeStart=true;
1700449691
1700449692
throwableFromStop=th;
1700449693
1700449694
}
1700449695
1700449696
这里设置了stopBeforeStart变量,标志着是在启动前设置了停止标志,在start方法中是这样校验的:
1700449697
1700449698
public synchronized void start(){
1700449699
1700449700
//分配栈内存,启动线程,运行run方法
1700449701
1700449702
start0();
1700449703
1700449704
//在启动前设置了停止状态
1700449705
1700449706
if(stopBeforeStart){
1700449707
1700449708
stop0(throwableFromStop);
1700449709
1700449710
}
1700449711
1700449712
}
1700449713
1700449714
//本地方法
1700449715
1700449716
private native void start0();
1700449717
1700449718
注意看start0方法和stop0方法的顺序,start0方法在前,也就是说即使stopBeforeStart为true(不可启动),也会先启动一个线程,然后再stop0结束这个线程,而罪魁祸首就在这里!
[
上一页 ]
[ :1.700449669e+09 ]
[
下一页 ]