龙空技术网

一个简单的python多线程实例

MrSHBK 302

前言:

此刻小伙伴们对“python多线程编程案例”大约比较注意,姐妹们都想要知道一些“python多线程编程案例”的相关资讯。那么小编同时在网络上搜集了一些有关“python多线程编程案例””的相关文章,希望姐妹们能喜欢,看官们一起来了解一下吧!

实现一个简单的python多线程,,程序会一直派生出子线程,知道用户输入‘q’后退出程序。执行效果如图:

完整代码如下:

import _threaddef child(tid): print('Hello from thread',tid)def parent(): i=0 while True: i+=1 _thread.start_new_thread(child,(i,)) if input()=='q':breakparent()

标签: #python多线程编程案例