线程run()方法和start()方法的区别
1. run()方法并不启动新线程,只是在主线程中调用了一个普通函数而已;
2. start()方法启动一个子线程,线程名就是我们定义的name;
总结:如果想启动多线程,就必须使用start()方法!
threading.current_thread().name —— 获取线程名
threading.current_thread().ident() —— 获取线程id
1. run()方法并不启动新线程,只是在主线程中调用了一个普通函数而已;
2. start()方法启动一个子线程,线程名就是我们定义的name;
总结:如果想启动多线程,就必须使用start()方法!
threading.current_thread().name —— 获取线程名
threading.current_thread().ident() —— 获取线程id