Listing 1 Thread creation with the CreateThread() function
#include <windows.h> #include <iostream> void thread_entry () { for ( int i = 10; i > 0; --i ) { Sleep ( 200 ); std::cout << "world" << std::endl; } } int main () { HANDLE thread = CreateThread ( NULL, 0, ( LPTHREAD_START_ROUTINE ) thread_entry, NULL, 0, NULL ); for ( int i = 10; i > 0; --i ) { Sleep ( 100 ); std::cout << "hello" << std::endl; } WaitForSingleObject ( thread, INFINITE ); return ( 0 ); }