File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -210,18 +210,18 @@ use std::sync::atomic::{AtomicBool, Ordering};
210210use std :: thread;
211211
212212fn main () {
213- let lock = Arc :: new (AtomicBool :: new (true )); // value answers "am I locked?"
213+ let lock = Arc :: new (AtomicBool :: new (false )); // value answers "am I locked?"
214214
215215 // ... distribute lock to threads somehow ...
216216
217- // Try to acquire the lock by setting it to false
218- while ! lock . compare_and_swap (true , false , Ordering :: Acquire ) { }
217+ // Try to acquire the lock by setting it to true
218+ while lock . compare_and_swap (false , true , Ordering :: Acquire ) { }
219219 // broke out of the loop, so we successfully acquired the lock!
220220
221221 // ... scary data accesses ...
222222
223223 // ok we're done, release the lock
224- lock . store (true , Ordering :: Release );
224+ lock . store (false , Ordering :: Release );
225225}
226226```
227227
You can’t perform that action at this time.
0 commit comments