I could write a long thread, but I thought this would be easier...
Code:
#include <windows.h>
#include <stdio.h>
#define NUM_THREADS 200
CRITICAL_SECTION cs;
DWORD WINAPI ThreadFunc(LPVOID lpParam)
{
EnterCriticalSection(&cs);
printf("Hello World, I'm thread# %d\n", (int)lpParam);
LeaveCriticalSection(&cs);
return 0;
}//ThreadFunc
int main()
{
DWORD dwThreadId;
HANDLE hThread[NUM_THREADS];
int n;
InitializeCriticalSection(&cs);
// create all the threads
for (n = 0; n < NUM_THREADS; n++)
{
hThread[n] = CreateThread(NULL, 0, ThreadFunc, (LPVOID)n, 0, &dwThreadId);
if (hThread == NULL)
fprintf(stderr, "Failed to create thread# %d", n);
}//for
// wait for all the threads to exit
for (n = 0; n < NUM_THREADS; n++)
{
if (hThread[n] != NULL)
WaitForSingleObject(hThread[n], INFINITE);
}//for
DeleteCriticalSection(&cs);
return 0;
}//main