Hi friends, I wrote a little program to practice multi-threading in VC2005. Everything seems to be OK, but it terminate after about 2 minutes with returned code 0 (0x0). This is my thread routine: Code: DWORD WINAPI StartMoving(void *param) { CMyBall *p = (CMyBall*)param; while(!isExited) { p->move(); //If the ball reachs bottom, top, left or right border, it will turn out if((p->x < p->R)||(p->x > (rectClient.right - rectClient.left)-p->R)) p->vx = -p->vx; if((p->y < p->R)||(p->y > (rectClient.bottom - rectClient.top)-p->R)) p->vy = -p->vy; WaitForSingleObject(g_displayMutex, INFINITE); InvalidateRect(g_hWnd, NULL, 0); Sleep(20); ReleaseMutex(g_displayMutex); } return 0; } Any explanation will be appreciated. Thanks