January 01, 2003
Multithreaded Programming with the Command Pattern
Multithreaded Programming with the Command Pattern
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 );
}
Previous Page |
1
|
2
|
3
|
4
|
5
|
6
Next Page