From b087cee9509a448c6a66ce675ce35ae2fbe2f2e0 Mon Sep 17 00:00:00 2001 From: zongzi531 Date: Wed, 16 Mar 2022 12:44:35 +0800 Subject: [PATCH] Fix typo in concurrency-with-threads/message-passing.md --- src/advance/concurrency-with-threads/message-passing.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/advance/concurrency-with-threads/message-passing.md b/src/advance/concurrency-with-threads/message-passing.md index d1aad470..dbf7ba23 100644 --- a/src/advance/concurrency-with-threads/message-passing.md +++ b/src/advance/concurrency-with-threads/message-passing.md @@ -226,7 +226,7 @@ fn main() { thread::sleep(Duration::from_secs(3)); println!("睡眠之后"); - println!("收到值 {}", rx.recv().unwrap()); + println!("receive {}", rx.recv().unwrap()); handle.join().unwrap(); } ``` @@ -239,7 +239,7 @@ fn main() { 发送之后 //···睡眠3秒 睡眠之后 -收到值 1 +receive 1 ``` 主线程因为睡眠阻塞了 3 秒,因此并没有进行消息接收,而子线程却在此期间轻松完成了消息的发送。等主线程睡眠结束后,才姗姗来迟的从通道中接收了子线程老早之前发送的消息。 @@ -279,11 +279,11 @@ fn main() { 发送之前 //···睡眠3秒 睡眠之后 -收到值 1 +receive 1 发送之后 ``` -可以看出,主线程由于睡眠被阻塞导致无法接收消息,因此子线程的发送也一直被阻塞,直到主线程结束睡眠并成功接收消息后,发送才成功:**发送之后**的输出是在**收到值 1**之后,说明**只有接收消息彻底成功后,发送消息才算完成**。 +可以看出,主线程由于睡眠被阻塞导致无法接收消息,因此子线程的发送也一直被阻塞,直到主线程结束睡眠并成功接收消息后,发送才成功:**发送之后**的输出是在**receive 1**之后,说明**只有接收消息彻底成功后,发送消息才算完成**。 #### 消息缓存