News for hackers. Stuff that matters.
Re:Concurrency in Rust by RasmusWL on Sunday March 27, 2016 @05:05PM (#11371552)
Can someone enlighten me as to why the first snippet has a data race? Won't the resulting array become [2,3,4]?

    let mut data = vec![1, 2, 3];

    for i in 0..3 {
        thread::spawn(move || {
            data[i] += 1;
        });
    }
Re:Concurrency in Rust by Manishearth on Sunday March 27, 2016 @05:57PM (#11371738)
Re:Concurrency in Rust by gsjs on Sunday March 27, 2016 @05:29PM (#11371637)
I don't think there's a data race there, but the compiler can't check that. What the compiler sees is more than one thread accessing the variable `data`, which could cause a data race.