n0va_sa

Python_thread_program_3

Sep 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import threading
  2. import time, os
  3.  
  4. def printThread():
  5.     print "Thread Name : " + threading.currentThread().getName() + " Starting"
  6.     time.sleep(3)
  7.     print "Thread Name : " + threading.currentThread().getName() + " Exiting"
  8.  
  9. def user_granted():
  10.     print "USER ACCESS FOR SYSTEM " +  os.uname()[1] + "Checking ..."
  11.     time.sleep(4)
  12.     print os.uname()[1] + " Access Granted"
  13.  
  14. def main():
  15.     thr = []
  16.     whr = []
  17.     for i in range(5):
  18.         t = threading.Thread(name="printThread "+str(i),target=printThread)
  19.         w = threading.Thread(name="ug"+str(i),target=user_granted)
  20.         thr.append(t)
  21.         whr.append(w)
  22.         t.start()
  23.         w.start()
  24.  
  25.  
  26. main()
Add Comment
Please, Sign In to add comment