#include<Windows.h>
#include<iostream>
using namespace std;
class Thread {
protected:
virtual void threadMain() {}
static unsigned long __stdcall __threadMain(void *args) {
Thread* self=(Thread*)args;
self->threadMain();
return 0;
}
public:
void run() {
CreateThread(0, 0, __threadMain, (void*)this, 0, 0);
}
};
class MyThread : public Thread {
public:
void threadMain() {
//run!!
}
}
이렇게하면
MyThread t;
t.threadMain(); 을 하면 스레드가 실행된다
'소프트웨어 > C/C++' 카테고리의 다른 글
C/C++] DLL 만들기 및 적용(dll export, dll import) (3) | 2017.02.23 |
---|---|
c] 프로세스 복제 fork (0) | 2014.05.31 |
c] data영역과 text영역 (1) | 2014.04.06 |
c] 문자열에서 char 찾기. strchr (0) | 2014.04.06 |
c/c++] CPP에서 strtok사용하기_ string객체를 char*로 변환 (0) | 2013.10.18 |
c/c++] 객체 배열 동적생성시 메모리반환 (0) | 2013.10.11 |
c/c++] Header와 소스코드분리 (0) | 2013.10.04 |