当前第2页 返回上一页
执行结果如下:
1 2 3 4 5 6 7 8 9 | thread MainThread is running...
thread LoopThread is running...
thread LoopThread >>> 1
thread LoopThread >>> 2
thread LoopThread >>> 3
thread LoopThread >>> 4
thread LoopThread >>> 5
thread LoopThread ended.
thread MainThread ended.
|
由于任何进程默认就会启动一个线程,我们把该线程称为主线程,主线程又可以启动新的线程,Python的threading模块有个current_thread()函数,它永远返回当前线程的实例。主线程实例的名字叫MainThread,子线程的名字在创建时指定,我们用LoopThread命名子线程。名字仅仅在打印时用来显示,完全没有其他意义,如果不起名字Python就自动给线程命名为Thread-1,Thread-2……
更多Python相关技术文章,请访问Python教程栏目进行学习!
以上就是python中如何安装threading的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
解决Python基于回溯法子集树模板实现8皇后问题
Python文件操作的介绍(代码示例)
Python中关于with的用法
Python tuple什么意思
Python定制类__str__(实例详解)
Python怎么计算时间差
Python装饰器的深入浅出
Python求两个数的最大公约数
Python之禅怎么打出来
Python能解偏微分方程吗
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python中如何安装threading