1. 程式人生 > >進程基礎整理

進程基礎整理

art init size threading thread import () port int

進程實例:
import threading

import time
def run(n):
print("task",n)
time.sleep(2)
t1 = threading.Thread(target=run,args = ("t1",))
t2 = threading.Thread(target=run,args = ("t2",))
t1.start()
t2.start()

多線程實現方法:
class MyThread(threading.Thread):
def __init__(self,n):
super(MyThread,self).__init__()

self.n = n
def run(self):
print("runint task",self.n)
t1 = MyThread("t1")
t1.run()
 

進程基礎整理