我有三个函数,分别写成三个线程跑着。
请问要是其中一个线程或是两个线程出错,要怎么重启,使它不影响程序的进行。
用thread.start() 能启动起来,要不要加入thread.join()
一直不明白join() 有什么用。貌似没有线程也能跑起来。
谢谢。
我有三个函数,分别写成三个线程跑着。
请问要是其中一个线程或是两个线程出错,要怎么重启,使它不影响程序的进行。
用thread.start() 能启动起来,要不要加入thread.join()
一直不明白join() 有什么用。貌似没有线程也能跑起来。
谢谢。
2 回答5.2k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
2 回答848 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决
join是等待线程结束,
至于一个线程或是两个线程出错,要怎么重启,
如果线程出错是异常,可以这样做
参考
join(timeout=None)
Wait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception – or until the optional timeout occurs.
Python catch thread exception