Sign in to follow this  
noatom

In what state is a thread when you create it?

Recommended Posts

noatom    927

So after you create the thread you can either join it, and wait for it to complete, or detach it, and let it run on its own. But what happens when you do neither? What is the initial state in which a thread gets created? (I'm using the thread feature in c++11)

Share this post


Link to post
Share on other sites
rip-off    10976
This overview seems to cover your question:

An initialized thread object represents an active thread of execution; Such a thread object is joinable, and has a unique thread id.

A default-constructed (non-initialized) thread object is not joinable, and its thread id is common for all non-joinable threads.

A joinable thread becomes not joinable if moved from, or if either join or detach are called on them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this