#include #include void thread2( void *p ) { printf( "[%d] Running\n", GetCurrentThreadId() ); } void thread1( void *p ) { while( 1 ) { Sleep( 2000 ); printf( "[%d] About to start a new thread\n", GetCurrentThreadId() ); _beginthread( thread2, 0, 1 ); } } void main( void ) { char buf[ 1024 ]; _beginthread( thread1, 0, 1 ); while( gets( buf ) ) { printf( "CMD: %s\n", buf ); } return; } /* output C:\test>junk2.exe [3120] About to start a new thread [5168] Running [3120] About to start a new thread [3944] Running [3120] About to start a new thread [6016] Running fred CMD: fred [3120] About to start a new thread [6996] Running [3120] About to start a new thread [6980] Running */