Simple thread wrapper class
- After creating this instance, a thread will be created by calling Start. And if this instance is destructed then it will be blocked until created thread is terminated.
- This class has the same operating process as System.Threading.Thread class of .NET framework.
General usage
- Creates a thread object and designates thread function as a parameter. The thread function is designated by constructor.
- Creating a thread object does not mean immediate thread execution. Start must be run.
- Either when calls Join or destructing the thread object, this waits until the running thread ends.
- Warning
- We recommend using std::thread instead of using this class.
You may create a routine that a thread will execute as Lambda Expression below.
CriticalSection critSec;
int totalWorkCount = 0;
volatile bool stopThread = false;
{
while (!stopThread)
{
CriticalSectionLock lock(critSec, true);
do_something();
totalWorkCount++;
}
});
th->Start();
do_something_or_wait();
stopThread = true;
th->Join();
print(totalWorkCount);