Skip to content

Commit

Permalink
restructured docs for thread and added links
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Poveda committed Apr 26, 2017
1 parent bdb6bb9 commit cf52121
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,28 +713,34 @@ struct Inner {

#[derive(Clone)]
#[stable(feature = "rust1", since = "1.0.0")]
/// A handle to a thread, its just an abstract reference and as such
/// it can be used to identify a thread (by name, for example). In most
/// usage cases, this struct is not used directly.
/// A handle to a thread.
///
/// You can use it to identify a thread (by name, for example). Most of the
/// time, there is no need to directly create a `Thread` struct using the
/// constructor, instead you should use a function like `spawn` to create
/// new threads, see the docs of [`Builder`] and [`spawn`] for more.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use std::thread::Builder;
///
/// for i in 0..5 {
/// let thread_name = format!("thread_{}", i);
/// thread::Builder::new()
/// .name(thread_name) // Now you can identify which thread panicked
/// // thanks to the handle's name
/// .spawn(move || {
/// if i == 3 {
/// panic!("I'm scared!!!");
/// }
/// })
/// .unwrap();
/// Builder::new()
/// .name(thread_name) // Now you can identify which thread panicked
/// // thanks to the handle's name
/// .spawn(move || {
/// if i == 3 {
/// panic!("I'm scared!!!");
/// }
/// })
/// .unwrap();
/// }
/// ```
/// [`Builder`]: ../../std/thread/struct.Builder.html
/// [`spawn`]: ../../std/thread/fn.spawn.html

pub struct Thread {
inner: Arc<Inner>,
}
Expand Down

0 comments on commit cf52121

Please sign in to comment.