title: Can C++11 tell if std::thread is active?
body: <p>To my surprise, a C++11 std::thread object that has finished executing, but has not yet been joined is still <a href="http://en.cppreference.com/w/cpp/thread/thread/joinable" rel="noreferrer">considered</a> an active thread of execution. This is illustrated in the following code example (built on Xubuntu 13.03 with g++ 4.7.3). Does anyone know if the C++11 standard provides a means to detect if a std::thread object is still actively running code?</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;chrono&gt;
  #include &lt;iostream&gt;
  #include &lt;pthread.h&gt;
  #include &lt;functional&gt;
  int main() {
      auto lambdaThread = std::thread([](){std::cout&lt;&lt;"Excuting lambda thread"&lt;&lt;std::endl;});
      std::this_thread::sleep_for(std::chrono::milliseconds(250));
      if(lambdaThread.joinable()) {
          std::cout&lt;&lt;"Lambda thread has exited but is still joinable"&lt;&lt;std::endl;
          lambdaThread.join();
      }
      return 0;
  }
  </code></pre>