Created
June 4, 2014 18:01
-
-
Save anonymous/bf03eca107838fbd2223 to your computer and use it in GitHub Desktop.
This file contains 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
static NTASKS: int = 10; | |
fn main() { | |
let mut array = [0u32, ..NTASKS]; | |
for i in range(0u32, NTASKS as u32) { | |
let x: &mut u32 = &mut array[i as uint]; | |
let ptr = x as *mut _; | |
spawn(proc() { | |
let inner_x = unsafe {&mut *ptr}; | |
*inner_x += i; | |
println!("inner_x: {}", *inner_x); | |
}); | |
} | |
println!("array: {}", array.as_slice()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment