From ec3e0e65ba11244842ad7902f8bd920ef7e9ead0 Mon Sep 17 00:00:00 2001 From: jkandpm Date: Wed, 18 Apr 2018 13:02:50 +0000 Subject: [PATCH] fix: potential endless loop (#22) * fix potential endless loop * update code as well --- book/zh-cn/07-thread.md | 1 + code/7/7.2.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/book/zh-cn/07-thread.md b/book/zh-cn/07-thread.md index 771d1f2..893acd2 100644 --- a/book/zh-cn/07-thread.md +++ b/book/zh-cn/07-thread.md @@ -153,6 +153,7 @@ int main() cond_var.notify_one(); } done = true; + notified = true; cond_var.notify_one(); }); diff --git a/code/7/7.2.cpp b/code/7/7.2.cpp index 7fd9d87..6f6e5a9 100644 --- a/code/7/7.2.cpp +++ b/code/7/7.2.cpp @@ -39,6 +39,7 @@ int main() cond_var.notify_one(); } done = true; + notified = true; cond_var.notify_one(); }); // 消费者线程