返回顶部

收藏

多线程练习

更多
import threading
import time
from sys import stdout

class mythread(threading.Thread):
    def __init__(self,threadname):
        threading.Thread.__init__(self, name = threadname)

    def run(self):
        for i in range(10):
            print(self.getName(),i)
            time.sleep(1)

thread1 = mythread('mythread')
thread1.start()

running = threading.currentThread()
time.sleep(5)
for i in range(5):
    stdout.write(str(i)+'\t')

标签:python

收藏

0人收藏

支持

0

反对

0

发表评论