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.
精彩评论