@@ -713,28 +713,34 @@ struct Inner {
713
713
714
714
#[ derive( Clone ) ]
715
715
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
716
- /// A handle to a thread, its just an abstract reference and as such
717
- /// it can be used to identify a thread (by name, for example). In most
718
- /// usage cases, this struct is not used directly.
716
+ /// A handle to a thread.
717
+ ///
718
+ /// You can use it to identify a thread (by name, for example). Most of the
719
+ /// time, there is no need to directly create a `Thread` struct using the
720
+ /// constructor, instead you should use a function like `spawn` to create
721
+ /// new threads, see the docs of [`Builder`] and [`spawn`] for more.
719
722
///
720
723
/// # Examples
721
724
///
722
725
/// ```
723
- /// use std::thread;
726
+ /// use std::thread::Builder ;
724
727
///
725
728
/// for i in 0..5 {
726
729
/// let thread_name = format!("thread_{}", i);
727
- /// thread:: Builder::new()
728
- /// .name(thread_name) // Now you can identify which thread panicked
729
- /// // thanks to the handle's name
730
- /// .spawn(move || {
731
- /// if i == 3 {
732
- /// panic!("I'm scared!!!");
733
- /// }
734
- /// })
735
- /// .unwrap();
730
+ /// Builder::new()
731
+ /// .name(thread_name) // Now you can identify which thread panicked
732
+ /// // thanks to the handle's name
733
+ /// .spawn(move || {
734
+ /// if i == 3 {
735
+ /// panic!("I'm scared!!!");
736
+ /// }
737
+ /// })
738
+ /// .unwrap();
736
739
/// }
737
740
/// ```
741
+ /// [`Builder`]: ../../std/thread/struct.Builder.html
742
+ /// [`spawn`]: ../../std/thread/fn.spawn.html
743
+
738
744
pub struct Thread {
739
745
inner : Arc < Inner > ,
740
746
}
0 commit comments