python 多线程框架

#!/usr/bin/python3

import threading


class myThread (threading.Thread):
    def __init__(self,形参1):
        threading.Thread.__init__(self)
        self.形参1 = 形参1

    def run(self):        
        handle(self.形参1)

def handle(形参1):
    # 把运行的主体写在这里
    print(111111111111, 形参1)
       
        
if __name__ == "__main__":
    # 创建新线程
    thread1 = myThread(实参1)
    thread2 = myThread(实参1)

    # 开启新线程
    thread1.start()
    thread2.start()
    thread1.join()
    thread2.join()
    print ("退出主线程")

你可能感兴趣的:(python,python,开发语言)