I need to start an additional stream in the main procedure, which will read the information for some of its value, and stop the main parent stream.
How can I get the main thread?
I need to start an additional stream in the main procedure, which will read the information for some of its value, and stop the main parent stream.
How can I get the main thread?
To stop the main thread and wait for the completion of the additional stream, add join()
after the start:
Thread thread = new Thread() { @Override public void run() { //код дополнительного потока } }; thread.start(); thread.join();
To control the main stream from the additional stream is in most cases not a very good solution. Try to organize the logic in such a way that such a need does not arise.
Source: https://ru.stackoverflow.com/questions/192421/
All Articles