• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

How can i start two worker threads Parallelly

Hello,

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
0
vihar123
Asked:
vihar123
1 Solution
 
AndyAinscowCommented:
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?

if(m_chk_cyclic.GetCheck()){  
   analysisThread = AfxBeginThread(AnalysisThread,this);
  if(m_chk_saveImages.GetCheck()){
  savingThread = AfxBeginThread(SavingThread,this);
  }
}
0
 
vihar123Author Commented:
Thank you,

Yes you  are right.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now