creekorful creekorful - 5 months ago 40
C++ Question

How to unpause thread in Qt

I wanna know if there is a way to unpause a sleeping thread in Qt

I pause the thread using QThread::msleep(ms) function

And i want to unpause the thread before time runs out

Is there any way to do it ?

Thank in advance, Creekorful

QMutex mut;

void InterruptMethod() {

void SleepMethod() {
  const int kTimeout = 5000;
  bool over_event_come = mut.tryLock(kTimeout); // here was sleep
  if (over_event_come) {
    // unlock from another place
  } else {
    // exit by timeout