Advertisement
parkdream1

thread.py

Jun 9th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import thread
  4. import time
  5.  
  6. # Define a function for the thread
  7. def print_time( threadName, delay):
  8.    count = 0
  9.    while count < 9999:
  10.       time.sleep(delay)
  11.       count += 1
  12.       print "%s: %s" % ( threadName, time.ctime(time.time()) )
  13.  
  14. # Create two threads as follows
  15. try:
  16.    thread.start_new_thread( print_time, ("Thread-1", 5, ) )
  17.    thread.start_new_thread( print_time, ("Thread-2", 5, ) )
  18. except:
  19.    print "Error: unable to start thread"
  20.  
  21. while 1:
  22.    pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement