n0va_sa

Python_thread_program_2

Sep 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import threading
  2. from random import randint
  3. import time
  4. def add(n1, n2):
  5.     print "%d + %d = %d"%(n1,n2,(n1+n2))
  6.     time.sleep(4)
  7.     return n1 + n2
  8.  
  9. def main():
  10.     thr = []
  11.     for i in range(5):
  12.         t = threading.Thread(target=add, args=(randint(1,700),randint(999,4000)))
  13.         thr.append(t)
  14.         t.start()
  15.  
  16. main()
Add Comment
Please, Sign In to add comment