I have created simple application for Windows CE 5.0 as a exercise for some multithreaded work. In WinMain I am calling twice function for creating threads:
myThread = CreateThread(NULL, 0, myThreadFunc(), NULL, 0, NULL);
myThread2 = CreateThread(NULL, 0, myThreadFunc2(), NULL, 0, NULL);
And functions executed in threads looks like this:
LPTHREAD_START_ROUTINE myThreadFunc()
{
Sleep(3000);
MessageBox(NULL, _T("thread 1"), _T("thread 1"), MB_OK);
return 0;
}
LPTHREAD_START_ROUTINE myThreadFunc2()
{
Sleep(2000);
MessageBox(NULL, _T("thread 2"), _T("thread 2"), MB_OK);
return 0;
}
I was expecting that program shows dialog box from thread 2 after 2 secs and after next 1 sec show the dialog box from thread 1. But actually when i am running this program it shows at first dialog box from thread 1 after 2 secs and then dialog box from thread 2 after next 3 secs. It seems like this treads are running sequentially and not simultaneously as I expected. Can anybody explain me this behavior, please?
I am using Windows CE 5.0, Windows eMbedded Visual C++ and Emulator for Windows CE STANDARDSDK_500.
Thank you for your help in advance.