// Release the lock to prevent a deadlock drop(guard); println!("thread {} is ready", i); // Blocks the current thread until all threads have rendezvoused here. my_barrier.wait(); println!("thread {} is done", i) }); }
// A barrier will block `n`-1 threads which call [`wait()`] and then wake // up all threads at once when the `n`th thread calls [`wait()`]. barrier.wait();