extern crate atom;
use atom::*;
use std::sync::{atomic::Ordering, Arc};
use std::thread;
fn main() {
let shared_atom = Arc::new(Atom::empty());
shared_atom.swap(Box::new(75), Ordering::AcqRel);
let threads: Vec<thread::JoinHandle<()>> = (0..8)
.map(|_| {
let shared_atom = shared_atom.clone();
thread::spawn(move || {
if let Some(v) = shared_atom.take(Ordering::Acquire) {
println!("I got it: {:?} :D", v);
} else {
println!("I did not get it :(");
}
})
})
.collect();
for t in threads {
t.join().unwrap();
}
}