循环创建线程(::_beginthreadex),CPU 100%问题
在主窗口类中
void CMainDlg::OnButton(UINT uNotifyCode, int nID, CWindow wndCtl)
{
HANDLE h[60];
for (int i = 0; i< 60; i++)
{
h[i] = (HANDLE)::_beginthreadex(NULL, 0, Dummy_SendThread, this, 0, NULL);
//Sleep(1);
}
}
界面上使用按钮触发创建多个线程,点击按钮有时界面会卡住,CPU100%; Dummy_SendThread函数里直接返回0;没做任何处理;
如果加上Sleep(1);时.好像就没问题;不知大家有没遇过?