History:
Multi Threading
Multi threading
Vytvoření a ukončení nového vlákna.
Code
#include <Windows.h> #include <stdio.h> DWORD WINAPI MultiHandler(void*); int number = 0; int main(int argc, char** argv) { HANDLE handle = CreateThread( 0, 0, &MultiHandler, (void*)NULL , 0, 0 ); for( int i=0; true; i++ ) { Sleep( 4951 ); number = i; if( i == 2 ) { printf("closing\n"); TerminateThread( handle, 0 ); } printf("------------------\n"); } return 0; } DWORD WINAPI MultiHandler(void* lp) { while(true) { Sleep( 200 ); printf("Vlákno %d\n", number); Sleep( 200 ); printf("A"); Sleep( 200 ); printf("B"); Sleep( 200 ); printf("C"); Sleep( 200 ); printf("D\n"); } return 0; }
Code.Tode.cz by Henry - 2014