Advertisement
rfmonk

threading_names.py

Feb 3rd, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import threading
  5. import time
  6.  
  7.  
  8. def worker():
  9.     print threading.currentThread().getName(), 'Starting'
  10.     time.sleep(2)
  11.     print threading.currentThread().getName(), 'Exiting'
  12.  
  13.  
  14. def my_service():
  15.     print threading.currentThread().getName(), 'Starting'
  16.     time.sleep(3)
  17.     print threading.currentThread().getName(), 'Exiting'
  18.  
  19. t = threading.Thread(name='my_service', target=my_service)
  20. w = threading.Thread(name='worker', target=worker)
  21. w2 = threading.Thread(target=worker)  # use default name
  22.  
  23. w.start()
  24. w2.start()
  25. t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement