Skip to content

Commit eb4acbc

Browse files
停止线程
1 parent 17d5f42 commit eb4acbc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Chapter03/stopThr01.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import threading
44
import time
55

6-
76
class TestThread(threading.Thread):
87
def __init__(self):
98
threading.Thread.__init__(self)
@@ -15,8 +14,9 @@ def terminate(self):
1514

1615
def run(self):
1716
count = 1
17+
thredName = threading.current_thread().getName()
1818
while self._running:
19-
print("threadName={0},count={1}".format(threading.current_thread().getName(),count))
19+
print("threadName={0},count={1}".format(thredName,count))
2020
count = count + 1
2121
time.sleep(1) # 暂停一秒钟
2222

0 commit comments

Comments
 (0)