1. 程式人生 > >python-多進程類封裝

python-多進程類封裝

true tar process 進程 pan imp style while {}

 1  #!/usr/bin/python
 2 import multiprocessing,time
 3 
 4 class ClockProcess(multiprocessing.Process):
 5     def __init__(self,value):
 6         super(ClockProcess,self).__init__()
 7         self.value=value
 8 
 9     def run(self):
10         n=5
11         while n>0:
12             print "the time is {}
".format(time.ctime()) 13 time.sleep(self.value) 14 n-=1 15 16 p=ClockProcess(3) 17 p.start() 18 19 while True: 20 time.sleep(2) 21 print "*"*40

python-多進程類封裝