Skip to content

Commit 196fc9c

Browse files
committed
fix indent error
缩进错误
1 parent 7e21d1b commit 196fc9c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

source/c12/p01_start_stop_thread.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ Python解释器在所有线程都终止后才继续执行代码剩余的部分
6969
n -= 1
7070
time.sleep(5)
7171
72-
c = CountdownTask()
73-
t = Thread(target=c.run, args=(10,))
74-
t.start()
75-
c.terminate() # Signal termination
76-
t.join() # Wait for actual termination (if needed)
72+
c = CountdownTask()
73+
t = Thread(target=c.run, args=(10,))
74+
t.start()
75+
c.terminate() # Signal termination
76+
t.join() # Wait for actual termination (if needed)
7777
7878
如果线程执行一些像I/O这样的阻塞操作,那么通过轮询来终止线程将使得线程之间的协调变得非常棘手。比如,如果一个线程一直阻塞在一个I/O操作上,它就永远无法返回,也就无法检查自己是否已经被结束了。要正确处理这些问题,你需要利用超时循环来小心操作线程。
7979
例子如下:
@@ -133,4 +133,4 @@ Python解释器在所有线程都终止后才继续执行代码剩余的部分
133133
p.start()
134134
135135
136-
再次重申,这段代码仅适用于 CountdownTask 类是以独立于实际的并发手段(多线程、多进程等等)实现的情况。
136+
再次重申,这段代码仅适用于 CountdownTask 类是以独立于实际的并发手段(多线程、多进程等等)实现的情况。

0 commit comments

Comments
 (0)