Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::sync::atomic::{AtomicI32, Ordering};
- fn main() {
- let x = std::sync::atomic::AtomicI32::new(0);
- let mut threads = vec![];
- for _ in 0..20 {
- let handle = std::thread::ThreadBuilder::new(|| {
- y.fetch_add(1, Ordering::Relaxed);
- }).spawn().unwrap();
- threads.push(handle);
- }
- dbg!(x.load(Ordering::Relaxed));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement