#include <string>
#include <iostream>
#include <windows.h>
using namespace std;
long WINAPI thread1()
{
for(int i = 0; i < 10; i++)
{
cout<<"Thread1"<<endl;
Sleep(1000);
}
return 0;
}
long WINAPI thread2()
{
for(int i = 0; i < 10; i++)
{
cout<<"Thread2"<<endl;
Sleep(200);
}
return 0;
}
int main(int argc, char **argv)
{
HANDLE hThread1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread1, 0, 0, 0);
HANDLE hThread2 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread2, 0, 0, 0);
WaitForSingleObject(hThread1, INFINITE);
WaitForSingleObject(hThread2, INFINITE);
CloseHandle(hThread1);
CloseHandle(hThread2);
return 0;
}