Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, technically any such object will wind up being built over a C-style thread library because C++ only just specified a stock <a href="http://en.cppreference.com/w/cpp/thread/thread" rel="noreferrer"><code>std::thread</code></a> model in c++0x, which was just nailed down and hasn't yet been implemented. The problem is somewhat systemic, technically the existing c++ memory model isn't strict enough to allow for well defined semantics for all of the 'happens before' cases. Hans Boehm wrote an paper on the topic a while back and was instrumental in hammering out the c++0x standard on the topic.</p> <p><a href="http://www.hpl.hp.com/techreports/2004/HPL-2004-209.html" rel="noreferrer">http://www.hpl.hp.com/techreports/2004/HPL-2004-209.html</a></p> <p>That said there are several cross-platform thread C++ libraries that work just fine in practice. Intel thread building blocks contains a tbb::thread object that closely approximates the c++0x standard and Boost has a boost::thread library that does the same.</p> <p><a href="http://www.threadingbuildingblocks.org/" rel="noreferrer">http://www.threadingbuildingblocks.org/</a></p> <p><a href="http://www.boost.org/doc/libs/1_37_0/doc/html/thread.html" rel="noreferrer">http://www.boost.org/doc/libs/1_37_0/doc/html/thread.html</a></p> <p>Using boost::thread you'd get something like:</p> <pre><code>#include &lt;boost/thread.hpp&gt; void task1() { // do stuff } void task2() { // do stuff } int main (int argc, char ** argv) { using namespace boost; thread thread_1 = thread(task1); thread thread_2 = thread(task2); // do other stuff thread_2.join(); thread_1.join(); return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload