python – time.sleep – 睡眠线程

import time
from threading import Thread

class worker(Thread):
    def run(self):
        for x in xrange(0,11):
            print x
            time.sleep(1)

class waiter(Thread):
    def run(self):
        for x in xrange(100,103):
            print x
            time.sleep(5)

def run():
    worker().start()
    waiter().start()
运行结果:
0
100 1 2 3 4 5101 6 7 8 9 10210

 

posted @ 2019-02-28 10:08  凯文队长  阅读(1097)  评论(0编辑  收藏  举报