开发者

How to stop a thread and invoke another

My program running on a one thread. And I have another thread and I want to stop current thread and invoke the second thread. And after second thread stops I want to invoke the first thre开发者_开发技巧ad again. How can I do this. Please help me.


You're looking for Thread.join method

like this (thread2 is the other thread you wanna wait for)

thread2.start();
thread2.join();
System.out.println("Done");


Use public final void join(long ms); method. Invoke it in your current thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜