Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 死锁-从主线程创建QThread_C++_Linux_Qt_Qt4 - Fatal编程技术网

C++ 死锁-从主线程创建QThread

C++ 死锁-从主线程创建QThread,c++,linux,qt,qt4,C++,Linux,Qt,Qt4,我试图调试一种情况,其中两个线程被锁定在同一个互斥锁(QMutex)上。 两个线程之间的连接是-一个线程是从另一个线程创建的。 即 第一个是主线程(gui线程),我从中创建另一个用户定义类的对象。从该对象的构造函数创建一个新线程。 这是一个错误的用法吗 //Some part of Code: void main() { MyMainThread *obj = new MyMainThread(); // this class inherits QWidget } //This clas

我试图调试一种情况,其中两个线程被锁定在同一个互斥锁(QMutex)上。 两个线程之间的连接是-一个线程是从另一个线程创建的。 即 第一个是主线程(gui线程),我从中创建另一个用户定义类的对象。从该对象的构造函数创建一个新线程。 这是一个错误的用法吗

//Some part of Code:

void main()
{
  MyMainThread *obj = new MyMainThread(); // this class inherits QWidget
}

//This class declaration is in another file
class Someobj
{
  SomeObj()
  {
  }
  StartAnotherObjThread()
  {
     AnotherObjthread obj = new AnotherObjThread(this);
     obj->start();       
  }
}

MyMainThread()
{
  SomeObj *obj = new SomeObj();
  obj->StartAnotherObjThread();
}

如果您发布了一些代码可能会有所帮助。如果可能,请共享整个代码,互斥锁在哪里?以及线程是如何同步的……我建议阅读,这比非常过时的Qt4文档所说的更有用、更好的实践。为Qt5描述的机制也适用于Qt4?