0

Here is my code snippet, Click here to view the full code.

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;
    }
}

Why can't I terminate the process in the other thread using pthread win32 ?

It should be terminated immediately, so how to terminate the process in the other thread? Thanks.

Kevin Dong
  • 5,001
  • 9
  • 29
  • 62
  • You could set a flag, and have the main thread continually checking if the flag is set. If it is set, the main thread could exit. – Brad Dec 01 '13 at 02:55
  • @Brad Yep, I think your concept is probably feasible, but how to terminate the process not in the main thread? – Kevin Dong Dec 01 '13 at 02:56
  • It's not portable, but you can always use [ExitProcess](http://msdn.microsoft.com/en-us/library/windows/desktop/ms682658\(v=vs.85\).aspx). – kichik Dec 01 '13 at 06:01

0 Answers0