thread问题求救
时间:2011-04-03
来源:互联网
import threading
counter = 0
class MyThread ( threading.Thread ):
def run ( self ):
global counter
for i in range(0,10000):
counter = counter + 1
t = list()
for x in range(0,20):
t.append(MyThread())
t[x].start()
for x in range(0,20):
t[x].join()
print counter
The program has been executed 10 times on a suitable machine (e.g., recent Linux version, recent python version), which has produced the following of output:
43491
34732
58987
41933
140221
46398
131750
45778
55603
88844
Run the program 5 times and report the output. Explain the differences in output.
counter = 0
class MyThread ( threading.Thread ):
def run ( self ):
global counter
for i in range(0,10000):
counter = counter + 1
t = list()
for x in range(0,20):
t.append(MyThread())
t[x].start()
for x in range(0,20):
t[x].join()
print counter
The program has been executed 10 times on a suitable machine (e.g., recent Linux version, recent python version), which has produced the following of output:
43491
34732
58987
41933
140221
46398
131750
45778
55603
88844
Run the program 5 times and report the output. Explain the differences in output.
作者: zhltmvp 发布时间: 2011-04-03
Are u in UW....haha~~~
作者: liyphoenix 发布时间: 2011-04-03
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28