본문 바로가기
1_ 맛있는프로그래밍/C and C++

C++ - 스레드를 돌리는 간단한 예제!

by 준환이형님 2011. 1. 26.

어찌나 예제가 다 어려운지..

가장 쉬운걸 찾아서 더 쉽게 만들었죠.. 저는 쉬워야 쓰는 남자니깐 ㅋ


#include <process.h>
#include <windows.h>
#include <stdio.h>

class AAA
{
public:
 static UINT WINAPI hello(LPVOID p)
 {
  while(true)
  {
 printf("AAA");
 Sleep(100);
  }
 }

 void start(void)
 {
  _beginthreadex(NULL,0, hello, (LPVOID)this,0,NULL);
 }
};

void main()
{
 AAA aaa;
 aaa.start();
  while(true)
  {
 printf("BBB");
 Sleep(100);
  }
}

끝. 쉽죠? ㅋ

'1_ 맛있는프로그래밍 > C and C++' 카테고리의 다른 글

C++ - 상속  (0) 2011.03.18
WinAPI - WinAPI에서 콘솔창 띄우기  (0) 2011.03.05
C++ - 템플릿 : 함수 템플릿 정의 하기  (0) 2011.01.24
C, C++ - 파일 입출력  (0) 2011.01.07
C++ - Stack Queue  (0) 2010.12.28