title: Use Multithreads in MFC C++
body: <p>I amnew to using multithreads on CPU, MFC C++. I am trying to initialize two of the CWinThreads and run them simultaneously as worker threads, here it is in my header file</p>
  
  <pre><code>    CWinThread      *m_thread;  
      CWinThread      *m_thread1; 
  </code></pre>
  
  <p>In my cpp file i am trying to call them like this</p>
  
  <pre><code>    CdecoderD3D9App *decoder_object_1 = new CdecoderD3D9App(460, 1);
      m_thread = AfxBeginThread(MainTread, decoder_object_1);
  
      CdecoderD3D9App *decoder_object_2 = new CdecoderD3D9App(460, 2);
      m_thread1 = AfxBeginThread(MainTread1, decoder_object_2);
  </code></pre>
  
  <p><code>CdecoderD3D9App</code> is my app class that i am passing to the threads and running its functions my threads functions are like this </p>
  
  <pre><code>UINT Ctesting_projectDlg::MainTread(LPVOID pParam)
  
  {
      clock_t t1, t2;
      t1 = clock(); 
      CdecoderD3D9App *decoder_object_1 = (CdecoderD3D9App *)pParam;
      char *video_source = "my_movie.mp4";
  
  
  
      decoder_object_1-&gt;InitInstance();
  
      decoder_object_1-&gt;run_program(video_source);
  
  
      t2 = clock(); 
      float diff = (((float)t2 - (float)t1) / 1000000.0F ) * 10;
  
  
      return 0;
  }
  
  
  UINT Ctesting_projectDlg::MainTread1(LPVOID pParam)
  
  {
      clock_t t1, t2;
      t1 = clock(); 
      CdecoderD3D9App *decoder_object_3 = (CdecoderD3D9App *)pParam;
  
      char *video_source = "my_movie.m2v";
  
  
  
      decoder_object_3-&gt;InitInstance();
  
  
  
  
      decoder_object_3-&gt;run_program(video_source);
      t2 = clock(); 
      float diff = (((float)t2 - (float)t1) / 1000000.0F ) * 10;
  
      return 0;
  }
  </code></pre>
  
  <p>When I am calling the thread functions only the second thread is running, the first thread start to run but as soon as the second thread is call upon the first thread stops. Is there anyway i can run them both simultaneously?
  I have to run basically four threads like these simultaneously in the program. Thank you.</p>