-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtut51.py
More file actions
31 lines (21 loc) · 699 Bytes
/
Copy pathtut51.py
File metadata and controls
31 lines (21 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#Chelin Tutorials 2011 All Rights Reserved.
#http://chelintutorials.blogspot.com/
#Threads
import time
import thread #imporar el modulo
#funcion que voy a colocar en thread
def imprimir_mensaje(mensaje):
while True:
print(mensaje)
time.sleep(1)
def main():
mensaje="Thread1" #variable aux
mensaje2="Thread2" #variable aux
#empiezo el thread
thread.start_new_thread(imprimir_mensaje, (mensaje,))
#empiezo otro thread
thread.start_new_thread(imprimir_mensaje, (mensaje2,))
x = raw_input("Estoy esperando q presiones enter...\n")
print("Termino la funcion main")
#se cerraran las threads activas de esta funcion.
main()