File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ use crate::sync::{Condvar, Mutex};
1313/// use std::sync::{Arc, Barrier};
1414/// use std::thread;
1515///
16- /// let mut handles = Vec::with_capacity(10);
17- /// let barrier = Arc::new(Barrier::new(10));
18- /// for _ in 0..10 {
16+ /// let n = 10;
17+ /// let mut handles = Vec::with_capacity(n);
18+ /// let barrier = Arc::new(Barrier::new(n));
19+ /// for _ in 0..n {
1920/// let c = Arc::clone(&barrier);
2021/// // The same messages will be printed together.
2122/// // You will NOT see any interleaving.
@@ -105,9 +106,10 @@ impl Barrier {
105106 /// use std::sync::{Arc, Barrier};
106107 /// use std::thread;
107108 ///
108- /// let mut handles = Vec::with_capacity(10);
109- /// let barrier = Arc::new(Barrier::new(10));
110- /// for _ in 0..10 {
109+ /// let n = 10;
110+ /// let mut handles = Vec::with_capacity(n);
111+ /// let barrier = Arc::new(Barrier::new(n));
112+ /// for _ in 0..n {
111113 /// let c = Arc::clone(&barrier);
112114 /// // The same messages will be printed together.
113115 /// // You will NOT see any interleaving.
You can’t perform that action at this time.
0 commit comments