-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.py
45 lines (35 loc) · 1006 Bytes
/
test1.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import threading
import time
def sayhello():
print(threading.active_count())
worker()
global t #Notice: use global variable!
t = threading.Timer(5.0, sayhello)
t.start()
def worker():
a = threading.Thread(target=aaa)
print(str(time.time())+' '*5+a.getName()+' '*5+'begain')
#print('a'+a.getName())
a.start()
def aaa():
begain = time.time()
for i in range(1,100000000):
i+=1
#time.sleep(60)
end = time.time()
print("I'am"+ " "*5 + threading.current_thread().getName())
print(end-begain)
if threading.current_thread().getName() == 'Thread-8':
b = 1/0
print(b)
if __name__ =="__main__":
# t = threading.Timer(5.0, sayhello)
# t.start()
#######################################################################
i=1
while True:
print(threading.active_count())
print(time.time())
time.sleep(5)
worker()
i+=1