hahahia

간단한 쓰레드(thread) 생성 소스 본문

Windows Programming/Windows::System

간단한 쓰레드(thread) 생성 소스

hahahia 2012. 3. 23. 15:11

/* thread.c

        made by hahahia

*/

#include <stdio.h>

#include <conio.h>

#include <Windows.h>

 

DWORD WINAPI print2(LPVOID lpParams){

        while(1)

        {

               printf("Thread2");

               Sleep(800);

        }

}

DWORD WINAPI print1(LPVOID lpParam)

{

        while(1)

        {      

               printf("Thread1");

               Sleep(500);

        }

}

int main()

{

        int a;

        CreateThread(NULL, 0, print1, NULL, 0 , NULL);              

        CreateThread(NULL, 0, print2, NULL, 0, NULL);

        while(1)

        {

               scanf("%d", &a);

               printf("%d\n", a);

        }

}

 


Comments