SHARE
TWEET

Untitled

a guest Oct 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::sync::atomic::{AtomicI32, Ordering};
  2.  
  3. fn main() {
  4.     let x = std::sync::atomic::AtomicI32::new(0);
  5.    
  6.     let mut threads = vec![];
  7.    
  8.     for _ in 0..20 {
  9.         let handle = std::thread::ThreadBuilder::new(|| {
  10.             y.fetch_add(1, Ordering::Relaxed);
  11.         }).spawn().unwrap();
  12.         threads.push(handle);
  13.     }
  14.     dbg!(x.load(Ordering::Relaxed));
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top