A way to destroy “thread” class

前端 未结 8 1432
甜味超标
甜味超标 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:50

    You should add dedicated thread management class (i.e. MyThreadMngr), that handles this and other tasks, like book keeping, owning the thread handles etc. The Thread itself should somehow signal to the thread manager that its going to terminate and MyThreadMngr should i.e. have a loop like Tom proposed.

    There will probably be more actions that suite into such a thread manager class.

提交回复
热议问题