C 为什么可以';我是否使用pthread win32在另一个线程中终止进程?
下面是我的代码片段,以查看完整的代码C 为什么可以';我是否使用pthread win32在另一个线程中终止进程?,c,pthreads-win32,C,Pthreads Win32,下面是我的代码片段,以查看完整的代码 int main (void) { //Multi-Thread pthread_t Key_Stroke_Func; pthread_create (&Key_Stroke_Func, NULL, (void*)Get_Key_Stroke, NULL); ........ } void *Get_Key_Stroke (void) { unsigned char Key_Stroke_1, Key_S
int main (void)
{
//Multi-Thread
pthread_t Key_Stroke_Func;
pthread_create (&Key_Stroke_Func, NULL, (void*)Get_Key_Stroke, NULL);
........
}
void *Get_Key_Stroke (void)
{
unsigned char Key_Stroke_1, Key_Stroke_2;
for(;;)
{
Key_Stroke_2 = getch ();
if (Key_Stroke_1 == 0xE0)
{
Move.Condition = UnRead;
if (Key_Stroke_2 == 0x48 && Draw.Direction != DN) // Press <Up>
Predict_Func (UP);
else
{
if (Key_Stroke_2 == 0x4F) // Press <END>
exit (EXIT_SUCCESS); // <----- This Line !
continue;
}
}
Key_Stroke_1 = Key_Stroke_2;
}
}
int main(无效)
{
//多线程
pthread_t Key_Stroke_Func;
pthread_create(&Key_Stroke_Func,NULL,(void*)Get_Key_Stroke,NULL);
........
}
void*Get_Key_笔划(void)
{
无符号字符键_笔划_1,键_笔划_2;
对于(;;)
{
Key_Stroke_2=getch();
如果(键\行程\ 1==0xE0)
{
Move.Condition=未读;
如果(键\u笔划\u 2==0x48&&Draw.Direction!=DN)//按
预测函数(UP);
其他的
{
如果(键\u行程\u 2==0x4F)//按
exit(exit_SUCCESS);//您可以设置一个标志,让主线程不断检查标志是否设置。如果设置了,主线程可以退出。@Brad Yep,我认为您的概念可能是可行的,但是如何在不在主线程中终止进程?它不可移植,但您可以随时使用。