Skip to content

Instantly share code, notes, and snippets.

@JSONOrona
Last active August 29, 2015 13:57
Show Gist options
  • Save JSONOrona/9378371 to your computer and use it in GitHub Desktop.
Save JSONOrona/9378371 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import thread
import time
# Global variables
MAX = 50
# Functions
def print_time( threadName, delay):
'''
Simple thread function, spawns off 6 threads
'''
max = MAX
count = 0
while count < max:
time.sleep(delay)
count += 1
print "%s: %s - Current count is [%s]" % ( threadName, time.ctime(time.time()), count )
# Create six threads as follows
try:
thread.start_new_thread( print_time, ("Thread-1", 1, ) )
thread.start_new_thread( print_time, ("Thread-2", 1, ) )
thread.start_new_thread( print_time, ("Thread-3", 1, ) )
thread.start_new_thread( print_time, ("Thread-4", 1, ) )
thread.start_new_thread( print_time, ("Thread-5", 1, ) )
thread.start_new_thread( print_time, ("Thread-6", 1, ) )
except:
print "Error: unable to start thread"
while 1:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment