Sintaxis
import time
import thread
def imprimir_mensaje(mensaje):
while True:
print (mensaje)
time.sleep(1)
def main():
mensaje = "Thread 1" #variable aux
mensaje2 ="Thread 2" #variable aux
#empezo el thread
thread.start_new_thread(imprimir_mensaje,(mensaje,))
thread.start_new_thread(imprimir_mensaje,(mensaje2,))
x = raw_input("Estoy esperando que presiones enter...\n")
print "Termino la funcion main"
main()
Corrida en pantalla del programa

No hay comentarios.:
Publicar un comentario