#include int counter=0; DWORD WINAPI ThreadFunc(LPVOID lpParam) { int i; for (i=0;i<10;i++) printf("hello from thread %d (counter=%d)\n",*(DWORD*)lpParam, counter++); return 0; } int main(VOID) { DWORD dwThreadId1, dwThreadId2; DWORD dwThrdParam1=1, dwThrdParam2=2; HANDLE hThread1, hThread2; hThread1 = CreateThread( NULL, // default security attributes 0, // use default stack size ThreadFunc, // thread function &dwThrdParam1, // argument to thread function 0, // use default creation flags &dwThreadId1); // returns the thread identifier hThread2 = CreateThread(NULL,0,ThreadFunc,&dwThrdParam2,0,&dwThreadId2); if (hThread1 == NULL || hThread2 == NULL) { printf("CreateThread failed"); } else { CloseHandle(hThread1); CloseHandle(hThread2); } Sleep(100); exit(0); }