Skip to content

Commit d2c1a9e

Browse files
committed
Merge pull request yidao620c#115 from fplust/patch-2
fix indent error
2 parents 4cf8bb0 + 196fc9c commit d2c1a9e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

source/c12/p01_start_stop_thread.rst

+5-5
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
例子如下:

0 commit comments

Comments
 (0)