History: Multi Threading
Multi threading
Creation and termination of the new thread.
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
Získejte registraci domén s tld .online, .space, .store, .tech zdarma!
Stačí si k jedné z těchto domén vybrat hosting Plus nebo Mega a registraci domény od nás dostanete za 0 Kč!
Objednat