python中如何安装threading


当前第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中关于正则捕获操作的示例

Python如何查找子字符串

Python和selenium对浏览器窗口进行处理的代码实例

Python 列表删除所有指定元素

简单易学的Python语言,黑客也喜欢她

Python文档在哪里

Python为什么是面向对象的

Python中什么是语句块?

如何用Python画三角形

怎么查看Python是否安装好

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...