A way to destroy “thread” class

前端 未结 8 1286
甜味超标
甜味超标 2021-02-06 18:22

Here is a skeleton of my thread class:

class MyThread {
public:
   virutal ~MyThread();

   // will start thread with svc() as thread entry point
   void start()         


        
8条回答
  •  粉色の甜心
    2021-02-06 18:33

    I reckon the easiest way to do this is to wrap the thread execution code in a loop

    while(isRunning())
    {
         ... thread implementation ...
    }
    

    You can also stop your thread by doing specific calls, for instance when you're using a WIN32 thread you can call TerminateThread on the thread handle in the destructor.

提交回复
热议问题