python多线程有两个参数怎么传(python从子线程中获得返回值的方法)
类别:脚本大全 浏览量:2276
时间:2022-03-31 22:56:55 python多线程有两个参数怎么传
python从子线程中获得返回值的方法如下所示:
|
# coding:utf-8 import time from threading import Thread def foo(number): time.sleep( 20 ) return number class MyThread(Thread): def __init__( self , number): Thread.__init__( self ) self .number = number def run( self ): self .result = foo( self .number) def get_result( self ): return self .result thd1 = MyThread( 3 ) thd2 = MyThread( 5 ) thd1.start() thd2.start() thd1.join() thd2.join() print thd1.get_result() print thd2.get_result() |
以上这篇python从子线程中获得返回值的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持开心学习网。
原文链接:https://blog.csdn.net/kelvinLLL/article/details/70755389
您可能感兴趣
- python交互执行shell脚本(python 利用文件锁单例执行脚本的方法)
- python yield 使用浅析(yii框架使用分页的方法分析)
- python面向对象使用方法(Python面向对象程序设计之私有属性及私有方法示例)
- python抽奖代码教程(python实现抽奖小程序)
- 正则表达式在python的中的应用(Python中正则表达式的用法总结)
- 用python编写一个gui(用 Python 构建漂亮的 GUI)
- python编写一个名片(详解Python做一个名片管理系统)
- python3.7手册中文版(Python3.4解释器用法简单示例)
- pythonselenium隐藏浏览器窗口(Python Selenium 之关闭窗口close与quit的方法)
- python中numpy常用函数(使用Python的SymPy库解决数学运算问题的方法)
- python转pdf教程(Python实现将HTML转成PDF的方法分析)
- python3知识点汇总(Python3几个常见问题的处理方法)
- python人脸识别实时教程(python dlib人脸识别代码实例)
- python如何遍历一个列表(说说如何遍历Python列表的方法示例)
- jupyter如何编写python(windows系统中Python多版本与jupyter notebook使用虚拟环境的过程)
- python3语法规则(Python3解释器知识点总结)
- 菲律宾游学(菲律宾游学中介机构)
- 菲律宾美食(菲律宾美食排行榜前十名)
- 菲律宾特产(菲律宾特产最值得买回国)
- 越南特产(越南特产首饰)
- TVB负评王连续挑战警察角色《使徒行者3》中将饰演卧底(TVB负评王连续挑战警察角色使徒行者3中将饰演卧底)
- 《精英律师》剧照首曝光,实力演员飙戏,演绎律政职场百态(精英律师剧照首曝光)
热门推荐
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9