title: Run threads in parallel in C++
body: <p>I am trying to do a dekker algorithm implementation for homework, I understand the concept but I'm not being able to execute two threads in parallel using C++0x.</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  class Homework2 {
  
  public:
      void run() {
          try {
              thread c1(&amp;Homework2::output_one, this);
  
              thread c2(&amp;Homework2::output_two, this);
  
  
          } catch(int e) {
              cout &lt;&lt; e &lt;&lt; endl;
          }
  
      }
  
      void output_one() {
          //cout &lt;&lt; "output one" &lt;&lt; endl;
      }
  
      void output_two() {
          //cout &lt;&lt; "output two" &lt;&lt; endl;
      }
  
  
  };
  
  int main() {
      try {
          Homework2 p2;
          p2.run();
      } catch(int e) {
          cout &lt;&lt; e &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>My problem is that the threads will return this error:</p>
  
  <pre><code>terminate called without an active exception
  Aborted
  </code></pre>
  
  <p>The only way to success until now for me has been adding c1.join(); c2.join(); or .detach();
  the problem is that join(); will wait for the threads to finish, and detach(); ... well Im not sure what detach does because there is no error but also no output, I guess it leaves the threads on their own...</p>
  
  <p>So all this to say:
  Does anybody knows how can I do this both threads to run parallel and not sequencial??
  The help is must appreciated!</p>
  
  <p>Thanks.-</p>
  
  <p>P.S:
  here is what I do for build:</p>
  
  <pre><code>g++ -o output/Practica2.out main.cpp -pthread -std=c++11 
  </code></pre>