线程的加入(join) 当线程使用join加入至另一个线程时,另 个线程会等待这个被加入的线程工作完 毕,然后再继续它的动作 join0的意思表示烀线程加入成为另一个线 程的流程之
线程的加入(join) • 当线程使用join()加入至另一个线程时,另 一个线程会等待这个被加入的线程工作完 毕,然后再继续它的动作 • join()的意思表示将线程加入成为另一个线 程的流程之一
线程的加入(join) Thread thread new Thread (new Runnable) i public void run()i try i catch(InterruptedException e) I printstackfrace( thread. start() try t // Thread B加入 Thread A thread join()i catch(InterruptedException e e. print StackTrace()
线程的加入(join) Thread threadB = new Thread(new Runnable() { public void run() { try { … } catch(InterruptedException e) { e.printStackTrace(); } } }); threadB.start(); try { // Thread B加入Thread A threadB.join(); } catch(InterruptedException e) { e.printStackTrace(); }