-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Description
Hi there :). I had a little issue when working with a mutex. The following code results in a null pointer error:
//standard library imports
use std::rt::thread::Thread;
use std::sync::{ Arc, Mutex};
fn main(){
//make mutex
let done = Arc::new( Mutex::new( false));
//spawn producer
println!("starting producer");
let mut prod_done = done.clone();
let producer = Thread::start(
proc(){ *( prod_done.lock()) = true;});
//spawn consumer
println!("starting consumer");
let consumer = Thread::start(
proc(){
while ! *( done.lock()) {}
});
//finish up
println!("joining threads");
producer.join();
consumer.join();
println!("threads joined");
}Thanks to some help from people on reddit, I managed to get around it with AtomicBool, but this error still stands.
Metadata
Metadata
Assignees
Labels
No labels