Create Thread
A console snippet that spawns a second thread with CreateThread and lets both threads print in parallel.
The minimal CreateThread pattern: define a function with the DWORD WINAPI callback signature, pass its address plus an optional data pointer to CreateThread, and let both the main thread and the new one run their loops. The commented lines show the CREATE_SUSPENDED variant with ResumeThread/SuspendThread if you need to control exactly when the worker starts and stops. Use it as the reference for adding background work to any Win32 console program.
#include <windows.h>
#include <stdio.h>
DWORD WINAPI Thread(LPVOID);
HANDLE Thread_Handle = NULL;
DWORD Thread_ID = 0;
DWORD WINAPI Thread(LPVOID data)
{
while(1)
printf("Thread 2\n");
return ((DWORD)data);
}
int main()
{
// Thread_Handle = CreateThread(NULL,0,Thread,(LPVOID)0,CREATE_SUSPENDED,&Thread_ID);
Thread_Handle = CreateThread(NULL,0,Thread,(LPVOID)0,0,&Thread_ID);
// ResumeThread(Thread_Handle);
while(1)
printf("Thread 1\n");
// SuspendThread(Thread_Handle);
return 0;
}