?? bees1.cpp
字號:
#include <stdio.h>
#include "CMcl.h"
class WorkerBee : public CMclThreadHandler {
private:
int m_BeeId;
BOOL m_bRun;
CMclThread *m_pcInternalThread;
public:
WorkerBee(int BeeId) : m_bRun(TRUE), m_BeeId(BeeId) {
m_pcInternalThread = new CMclThread(this);
};
~WorkerBee() {
// cleanup the thread object...
delete m_pcInternalThread;
};
void Stop(void) {
// tell the thread member object to stop...
m_bRun = FALSE;
// wait for the thread to exit...
m_pcInternalThread->Wait(INFINITE);
};
unsigned ThreadHandlerProc(void) {
while (m_bRun) {
// buzz around...
printf( "I am bee #%d.\n", m_BeeId);
}
return NO_ERROR;
};
};
int main( int argc, char *argv[]) {
// create 2 bees...
WorkerBee FirstBee(1);
WorkerBee SecondBee(2);
// let the bees buzz..
Sleep(2000);
// stop the bees...
FirstBee.Stop();
SecondBee.Stop();
// all done...
return NO_ERROR;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -