<windows.h>
DWORD WINAPI ThreadFunc(LPVOID);
int main()
{
HANDLE hThrd;
DWORD threadId;
int i;
//Create 5 threads reusing
for (i=0; i<5; i++)
{
hThrd = CreateThread(NULL,
0,
ThreadFunc,
(LPVOID)i,
0,
&threadId );
if (hThrd)
{
printf("Thread launched %d\n", i);
CloseHandle(hThrd);
}
}
// Wait for the threads to complete by putting base thread to sleep.
// We'll see a better way of doing this later.
Sleep(2000);
return EXIT_SUCCESS;
}
1. Use pastebin.com for long codes, don't paste long codes here 2. U can compile that code with Visual studio and Mingw-GCC
Обсуждают сегодня