import\ threading\ import\ time\ def\ target\ (sleep\ ):\ \ ttime\ .sleep\ (sleep\ )\ \ tprint\ (\ "当前线程",\ threading\ .current_thread\ (\ ).name\ ,\ '',\ 'sleep',\ sleep\ )\ \ if\ name\ ==\ 'main':\ \ tt1\ =\ threading\ .Thread\ (name\ =\ 't1'\ ,\ target\ =\ target\ ,\ args\ =\ (1,\ )\ )\ \ tt2\ =\ threading\ .Thread\ (name\ =\ 't2'\ ,\ target\ =\ target\ ,\ args\ =\ (2,\ )\ )\ \ tt1\ .start\ (\ )\ \ tt2\ .start\ (\ )\ \ tt1\ .join\ (\ )\ \ tt2\ .join\ (\ )\ \ tprint\ (\ "结束"\ )

Python 多线程:join() 方法的使用与示例

原文地址: https://www.cveoy.top/t/topic/pT7X 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录