Last active
August 29, 2015 13:57
-
-
Save JSONOrona/9378371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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