lunes, 12 de noviembre de 2018

practica con hilos



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import time
import thread
 
def imprimir_mensaje(mensaje):
    while True:
        print(mensaje)
        time.sleep(1)
 
 
def main():
    mensaje="Thread1"
    mensaje2="Thread2"
    #empiezo el thread
    thread.start_new_thread(imprimir_mensaje,(mensaje,))
    thread.start_new(imprimir_mensaje,(mensaje2,))
    x = raw_input("Estoy esperando que presiones enter...\n")
 
    print("Termino la funcion main")
 
main()

No hay comentarios.:

Publicar un comentario