diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 3a876e05eccbd..7ad6b124e3a38 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -40,13 +40,16 @@ use crate::mem; /// }); /// /// // each thread starts out with the initial value of 1 -/// thread::spawn(move|| { +/// let t = thread::spawn(move|| { /// FOO.with(|f| { /// assert_eq!(*f.borrow(), 1); /// *f.borrow_mut() = 3; /// }); /// }); /// +/// // wait for the thread to complete and bail out on panic +/// t.join().unwrap(); +/// /// // we retain our original value of 2 despite the child thread /// FOO.with(|f| { /// assert_eq!(*f.borrow(), 2);