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 thread 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.