为什么_kbhit()冻结线程?

时间:2013-04-13 20:05:20

标签: c++ multithreading visual-studio-2012

我想知道为什么循环中的kbhit()不允许工作线程,在下面的代码中必须有一个输出到屏幕“Test!”,但它没有发生。为什么呢?

#include <iostream>
#include <process.h>
#include <conio.h>

using namespace std;

void Thread(void *par)
{
        while (true)
        {
            cout<<"Test!"<<endl;
        };
} 

int main(int argc, char* argv[])
{ 
    _beginthread( Thread, 0, NULL);
    while(!_kbhit());
    return 0;
}

0 个答案:

没有答案
相关问题