Created
July 16, 2018 20:36
-
-
Save pftbest/928138387029a3e391909ea74992d061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate servo_arc; | |
| use std::thread; | |
| use servo_arc::Arc; | |
| fn main() { | |
| let a1 = Arc::new(0); | |
| let mut a2 = a1.clone(); | |
| let t1 = thread::spawn( | |
| move || { | |
| for _ in 0..10 { | |
| let _z: u32 = *a1; | |
| } | |
| drop(a1); | |
| } | |
| ); | |
| let t2 = thread::spawn( | |
| move || { | |
| loop { | |
| match Arc::get_mut(&mut a2) { | |
| None => {} | |
| Some(m) => { | |
| *m = 1u32; | |
| return; | |
| } | |
| } | |
| } | |
| } | |
| ); | |
| t2.join().unwrap(); | |
| t1.join().unwrap(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment