Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 33_concurrency/examples/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let pair = Arc::new((Mutex::new(false), Condvar::new()));
let pair2 = Arc::clone(&pair);

thread::spawn(move || {
let t1 = thread::spawn(move || {
let (lock, cvar) = &*pair2;

// 通过离开作用域来释放锁,否则主线程会一直阻塞在获取锁上
Expand All @@ -34,5 +34,5 @@ fn main() {
eprintln!("Worker started!");

// 等待 worker 线程
thread::sleep(Duration::from_secs(3600));
t1.join().unwrap();
}