好吧,我的問題聽起來很混亂,但實際上很簡單。 我有一個Runnable啓動另一個Runnable實例。 所以基本上:在Runnable中啓動Runnable?
runnable1 - > runnable2
是否runnable1活着,只要runnable2是活着還是不runnable1結束時runnable2開始?
Runnable runnable1;
Runnable runnable2;
runnable1 = new Runnable()
{
public void run()
{
runnable2 = new Runnable()
{
public void run()
{
//Code here
}
};
(new Thread(runnable2)).start();//Now that runnable 2 is started, does runnable 1 temrinate??
}
};
(new Thread(runnable1)).start();//This starts first
它會,如果你調用線程運行的runnable2 join(),否則不會 – white
感謝您的及時響應。因此,如果我保持原樣,那麼runnable1會在啓動runnable2時立即終止? 對不起,只是雙重檢查。 – Aci89
是的,這是正確的 – white