import threading
import time
import random

def threadFun():
    for i in range(10):
        print("ThreadFun - %d" %i)
        time.sleep(random.randrange(0,2))

class ThreadClass(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        for i in range(10):
            print("ThreadClass - %d" %i)
            time.sleep(random.randrange(0,2))

if __name__ == "__main__":
    tFunc = threading.Thread(target = threadFun)
    tCls = ThreadClass()
    tFunc.start()
    tCls.start()
    tFunc.join()
    tCls.join()

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2021-12-21
  • 2021-08-13
  • 2021-10-05
猜你喜欢
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2021-08-15
  • 2021-12-16
相关资源
相似解决方案