diff options
| -rw-r--r-- | library/std/src/thread/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0c1ffeb1a79..f8f64117113 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1402,6 +1402,15 @@ impl<T> JoinHandle<T> { pub fn join(mut self) -> Result<T> { self.0.join() } + + /// Checks if the the associated thread is still running its main function. + /// + /// This might return `false` for a brief moment after the thread's main + /// function has returned, but before the thread itself has stopped running. + #[unstable(feature = "thread_is_running", issue = "none")] + pub fn is_running(&self) -> bool { + Arc::strong_count(&self.0.packet.0) > 1 + } } impl<T> AsInner<imp::Thread> for JoinHandle<T> { |
