// Allen Kennedy Jr. // ThreadClass.cpp #include "ThreadClass.h" #include ThreadClass::ThreadClass() { } ThreadClass::~ThreadClass() { } void ThreadClass::Start() { go = true; _beginthread( ThreadClass::Running, 0, this); } void ThreadClass::Stop() { go = false; } void ThreadClass::Running(void *Mythis) { // recast 'this' pointer from void to ThreadClass so that this static // member function may access private member variables. ThreadClass * InstPtr = (ThreadClass *) Mythis; while(1) { // do something interesting Here // like calculating pi to it's last digit. // or call another member function! // check to see if the thread should stop now if (InstPtr->go == false) break; } // Stop the thread _endthread(); }