Home > other > How to solve the thread lock after an exception occurs, perform sys. The exit () code lead to termin
How to solve the thread lock after an exception occurs, perform sys. The exit () code lead to termin
Time:10-15
I want to reach the purpose of: there are multiple be locked thread is running, if one thread exception happens, let program exits, echo other threads run no longer as a result,
But I found that if the program directly, the lock can not be released, the terminal will be stuck, I wrote a sample is as follows:
If first release to exit the program again, this time the program can be normal, but the content of the other threads will be displayed
Google a day also didn't find a way, how can I modify to achieve: a thread directly exit exception occurs, and other threads is not implemented? Hope everybody who walked past can give younger brother a prompt answer, crab crab
CodePudding user response:
I understand is executive, test1 test2 is executed, the output is according to the queue,
Can have a try if test2 is long enough, look to whether be interrupted,
Place of action test2 For I in range (100) : Print (' test do ', I) Sleep (1)