【发布时间】:2016-01-22 21:30:53
【问题描述】:
我编写基本线程程序:
import threading
初始化线程
class OpenThread (threading.Thread):
def __init__(self, threadID):
threading.Thread.__init__(self)
self.threadID = threadID
def run(self):
print thread.threadID
for tID in range(0, 5):
thread = OpenThread(tID)
thread.start()
最后 5 个尝试的输出在这里:
####try 1
0
1
2
3
4
####try 2
0
1
2
3
4
####try 3
0
2
23
4
####try 4
0
1
2
3
4
####try 5
0
1
3
34
我使用 PyCharm 作为 IDE。 我不明白为什么会有空格字符以及为什么更多线程参数得到相同的值
【问题讨论】:
标签: python multithreading python-2.7 pycharm python-multithreading