Skip to content

Instantly share code, notes, and snippets.

@zeldani
Created February 27, 2014 14:50
Show Gist options
  • Save zeldani/9251513 to your computer and use it in GitHub Desktop.
Save zeldani/9251513 to your computer and use it in GitHub Desktop.
#!/usr/bin/python:
import thread
import time
def print_time (nomedothread, delay):
conta = 0
while conta < 5:
time.sleep(delay)
conta += 1
print "%s: %s" % (nomedothread, time.ctime(time.time()) )
# Criando o thread:
try:
thread.start_new_thread( print_time, ("Thread-1", 2, ) )
thread.start_new_thread( print_time, ("Thread-2", 4, ) )
except:
print "Erro: nao foi possivel iniciar o thread."
while 1:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment