Skip to content

Instantly share code, notes, and snippets.

@samukasmk
Forked from zeldani/thread1.py
Last active August 29, 2015 14:27
Show Gist options
  • Save samukasmk/3710a318c674028f3db0 to your computer and use it in GitHub Desktop.
Save samukasmk/3710a318c674028f3db0 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