Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. import threading, time
  2.  
  3. threadLimiter = threading.Semaphore(5)
  4.  
  5. class EncodeThread(threading.Thread):
  6.     def __init__(self, count):
  7.         self.count = count
  8.         threading.Thread.__init__(self)
  9.     def run(self):
  10.         threadLimiter.acquire()
  11.         try:
  12.             print(self.count)
  13.             time.sleep(10)
  14.         finally:
  15.             threadLimiter.release()
  16.  
  17. for i in range(100):
  18.     EncodeThread(i).start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement