#include <iostream>
#include <Windows.h>
#define THREAD_COUNT 2
DWORD WINAPI threadFun1(void *lpVoid)
{
int b = 0;
for (int i = 0; i < 15; i++)
{
std::cout << i <<" - Fun1()" << std::endl;
}
return 0;
}
DWORD WINAPI threadFun2(void *lpVoid)
{
int b = 0;
for (int i = 0; i < 15; i++)
{
std::cout << i <<" - Fun2()" << std::endl;
}
return 0;
}
int main()
{
HANDLE hThread[THREAD_COUNT];
hThread[0] = CreateThread(NULL, 0, ::threadFun1, NULL, 0, NULL);
hThread[1] = CreateThread(NULL, 0, ::threadFun2, NULL, 0, NULL);
for (int i = 0; i < 15; i++)
{
std::cout << i <<" - main()" << std::endl;
}
WaitForMultipleObjects(THREAD_COUNT, hThread,true, INFINITE);
CloseHandle(hThread[0]);
CloseHandle(hThread[1]);
return 0;
}
출처: https://tt91.tistory.com/18 [티티의 게임 & 개발 블로그]