Package dics :: Module ThreadTest
[hide private]
[frames] | no frames]

Source Code for Module dics.ThreadTest

 1  #!/usr/bin/env python 
 2  #simple code which uses threads 
 3   
 4  import time 
 5   
 6  from threading import Thread 
 7   
8 -class MyThread(Thread):
9
10 - def __init__(self,bignum):
11 12 Thread.__init__(self) 13 self.bignum=bignum
14
15 - def run(self):
16 17 for l in range(10): 18 for k in range(self.bignum): 19 res=0 20 for i in range(self.bignum): 21 res+=1
22 23
24 -def test():
25 bignum=1000 26 thr1=MyThread(bignum) 27 thr1.start() 28 thr1.join()
29 30 if __name__=="__main__": 31 test() 32