1 from time import ctime,sleep
2 import threading
3 def music():
4 for i in range(2):
5 print ("I was listening to music. %s" %ctime())
6 sleep(4)
7
8 def move():
9 for i in range(2):
10 print ("I was at the movies! %s" %ctime())
11 sleep(5)
12 def eat():
13 for i in range(2):
14 print ("I was at the eats! %s" %ctime())
15 sleep(10)
16 Treads=[]
17 t1 = threading.Thread(target=music)
18 Treads.append(t1)
19 t2 = threading.Thread(target=move)
20 Treads.append(t2)
21 t3 = threading.Thread(target=eat)
22 Treads.append(t3)
23 if __name__ == '__main__':
24 for t in Treads:
25 t.setDaemon(True)
26 t.start()
27 for t in Treads:
28 t.join()
29 print ("all over %s" %ctime())