[thread.jthread.class.general]

# 32 Concurrency support library [[thread]](./#thread)

## 32.4 Threads [[thread.threads]](thread.threads#thread.jthread.class.general)

### 32.4.4 Class jthread [[thread.jthread.class]](thread.jthread.class#general)

#### 32.4.4.1 General [thread.jthread.class.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1924)

The class jthread provides a mechanism
to create a new thread of execution[.](#1.sentence-1)

The functionality is the same as for
class thread ([[thread.thread.class]](thread.thread.class "32.4.3 Class thread"))
with the additional abilities to provide
a stop_token ([[thread.stoptoken]](thread.stoptoken "32.3 Stop tokens")) to the new thread of execution,
make stop requests, and automatically join[.](#1.sentence-2)

[ð](#lib:jthread)

namespace std {class jthread {public:// typesusing id = thread::id; using native_handle_type = thread::native_handle_type; // [[thread.jthread.cons]](thread.jthread.cons "32.4.4.2 Constructors, move, and assignment"), constructors, move, and assignment jthread() noexcept; template<class F, class... Args> explicit jthread(F&& f, Args&&... args); ~jthread();
 jthread(const jthread&) = delete;
 jthread(jthread&&) noexcept;
 jthread& operator=(const jthread&) = delete;
 jthread& operator=(jthread&&) noexcept; // [[thread.jthread.mem]](thread.jthread.mem "32.4.4.3 Members"), membersvoid swap(jthread&) noexcept; bool joinable() const noexcept; void join(); void detach();
 id get_id() const noexcept;
 native_handle_type native_handle(); // see [[thread.req.native]](thread.req.native "32.2.3 Native handles")// [[thread.jthread.stop]](thread.jthread.stop "32.4.4.4 Stop token handling"), stop token handling stop_source get_stop_source() noexcept;
 stop_token get_stop_token() const noexcept; bool request_stop() noexcept; // [[thread.jthread.special]](thread.jthread.special "32.4.4.5 Specialized algorithms"), specialized algorithmsfriend void swap(jthread& lhs, jthread& rhs) noexcept; // [[thread.jthread.static]](thread.jthread.static "32.4.4.6 Static members"), static membersstatic unsigned int hardware_concurrency() noexcept; private: stop_source ssource; // *exposition only*};}
