📄 thread.h
字号:
//This piece of code has been written in University of Hull by
//Warren Viant then Head of Department
//in Department of Computer Science
//Some alteration have been made by me
#pragma once
#include <windows.h>
#include <process.h> /* _beginthread, _endthread */
#include <stddef.h>
#include <stdlib.h>
class Thread
{
private:
HANDLE _hThread;
bool _terminate;
bool _isRunning;
static unsigned __stdcall threadFunc(void *param) {
if (param)
return ((Thread*)param)->run();
return 1; // Return error
}
public:
Thread() : _hThread(0), _terminate(false) {}
virtual ~Thread() {}
void terminate() { _terminate = true; _isRunning = false; CloseHandle(_hThread);
_hThread=0; }
bool isTerminated() const { return _terminate; }
bool isThreadRunning()const{ return _isRunning ; }
void reset() { _terminate = false; _isRunning = false ;}
void SetRunningStatus() { _isRunning = true ;}
HANDLE start();
void waitForTermination();
virtual int run() = 0;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -