當前位置:編程學習大全網 - 網站源碼 - java 多線線程start和join

java 多線線程start和join

//妳試壹下我這種方法,應該是因為妳的線程沒有啟動,還有線程執行完成的先後順序,在妳//打印這壹句話的方式來看,是無法準確判斷的,我在join方法裏面加了10ms的延時,可以達//到妳說的效果

package?test;

public?class?TestThread?{

public?static?void?main(String[]?args)?{

//?TODO?Auto-generated?method?stub

try?{

Thread?t?=?new?Thread(new?Runnable()?{

@Override

public?void?run()?{

//?TODO?Auto-generated?method?stub

System.out.println("in------------");

}

});

t.start();

t.join(10);

}?catch?(InterruptedException?e)?{

//?TODO?Auto-generated?catch?block

e.printStackTrace();

}

System.out.println("out--------------");

}

}

  • 上一篇:Nodejs微信支付(koa框架)
  • 下一篇:C#中多個button的功能壹致怎麽寫壹個button的代碼控制全部的button
  • copyright 2024編程學習大全網