#-*-utf-8-*-
import threading,time
x='out'
class MyThread(threading.Thread):
def __init__(self,threadname):
threading.Thread.__init__(self, name=threadname)
def run(self):
global x 调用外部变量
for i in range(10):
print x
time.sleep(2)
if __name__ == '__main__':
obj = MyThread("this is my thread")
obj.start()
print "main is over"
阅读(810) | 评论(0) | 转发(1) |