Skip to content

Instantly share code, notes, and snippets.

Created June 4, 2014 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/bf03eca107838fbd2223 to your computer and use it in GitHub Desktop.
Save anonymous/bf03eca107838fbd2223 to your computer and use it in GitHub Desktop.
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