How can i start two worker threads Parallelly

Posted on 2005-04-14
Last Modified: 2013-11-20

I used the following code in one function. From this i am trying to start two threads Parallelly. But i observed in debug mode, after "AnalysisThread" finishes "SavingThread" is starting. Is it write code ?. If not please tell me how can i start these two threads at a time?
The checking coditions are needed, because some times i need to start one thread and in some cases i need to start two threads.

if(m_chk_cyclic.GetCheck() == TRUE){  
   analysisThread = AfxBeginThread(AnalysisThread,this);
if(m_chk_cyclic.GetCheck() == TRUE){
  if(m_chk_saveImages.GetCheck() == TRUE){
  savingThread = AfxBeginThread(SavingThread,this);

Thanks in advance
Question by:vihar123
    LVL 43

    Accepted Solution

    It should be OK but you could write it fractionally better.  Is the AnalysisThread finishing so fast you only think they are happing one after the other?

       analysisThread = AfxBeginThread(AnalysisThread,this);
      savingThread = AfxBeginThread(SavingThread,this);

    Author Comment

    Thank you,

    Yes you  are right.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now