Home > Software engineering >  I use MFC Createthread create several threads, but always open when there are several chains, to res
I use MFC Createthread create several threads, but always open when there are several chains, to res

Time:10-07

Th1=CreateThread (NULL, 0, Game_Paint, this, 0, NULL);
While (Th1==NULL)
{
Th1=CreateThread (NULL, 0, Game_Paint, this, 0, NULL);
}
Th2=CreateThread (NULL, 0, PlayAct, this, 0, NULL);
While (Th2==NULL)
{
Th2=CreateThread (NULL, 0, PlayAct, this, 0, NULL);
}
"Th3"=CreateThread (NULL, 0, InitGame, this, 0, NULL);

While (" Th3 "==NULL)
{
"Th3"=CreateThread (NULL, 0, InitGame, this, 0, NULL);
}
Th4=CreateThread (NULL, 0, JudgeMent, and this, 0, NULL);
While (Th4==NULL)
{
Th4=CreateThread (NULL, 0, JudgeMent, and this, 0, NULL);
}


Th6=CreateThread (NULL, 0, Texiao, this, 0, NULL);


While (Th6==NULL)
{
Th6=CreateThread (NULL, 0, Texiao, this, 0, NULL);
}

Th5=CreateThread (NULL, 0, EnermyGo, this, 0, NULL);
While (Th5==NULL)
{
Th5=CreateThread (NULL, 0, EnermyGo, this, 0, NULL);
}


M_hThread=CreateThread (NULL, 0, EnermyAct, this, 0, NULL);

While (m_hThread==NULL)
{
M_hThread=CreateThread (NULL, 0, EnermyAct, this, 0, NULL);
}


It is useless,,,, meowed

CodePudding user response:

Add a sleep after CreateThread (100).

CodePudding user response:

"Windows core programming"

CodePudding user response:

Use MFC AfxBeginThread (Game_Paint, this, this thread development function better.

CodePudding user response:

Try this AfxBeginThread
M_pThread=AfxBeginThread (DataRecvThreadFunc, this, THREAD_PRIORITY_NORMAL, 0, 0, NULL);

CodePudding user response:

Solved the
  • Related