#include "UmThread.h" #include #include #include #include #include UmThread::UmThread(IRunnable* runnable) : mIsRunning(false), mpRunnable(runnable) { } UmThread::~UmThread() { delete mpRunnable; } UINT UmThread::ThreadFunc(LPVOID lpParam) { UmThread* pThread = (UmThread*)lpParam; if (pThread == NULL) { return -1; } pThread->mIsRunning = true; pThread->OnRun(); pThread->mIsRunning = false; return 0; } int UmThread::Start() { mHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadFunc, (VOID*)this, 0, &mThreadID); ::CloseHandle(mHandle); // http://guanyue7613.blog.163.com/blog/static/885147420127353735454/ return 0; } int UmThread::Stop() { return 0; } void UmThread::OnRun() { if (mpRunnable == 0) { return ; } mpRunnable->OnRun(); }; void UmThread::Sleep(int milliSec) { ::Sleep(milliSec); }