Program unexpectedly finished using C++11 thread
Unsolved
General and Desktop
-
Hi, I have encounter an issue that when I added C++ thread, program has unexpectedly finished.
To begin with, I call thedrawObject(it);
iteratively to draw 9 objects, and it works fine. When I tried to use multithreading to complete this task, the process was ended forcefully.std::vector<std::thread> threads; int i = 1; for (auto it : solarSystem->getObjects()){ if (it->visiblity()){ glBindTexture(GL_TEXTURE_2D, texture[i]); threads.push_back(std::thread(drawObject,it)); // drawObject(it); } i++; } for_each(threads.begin(), threads.end(), mem_fn(&std::thread::join));
-
what is drawObject doing ? Are you doing something with UI here ? Are you creating some widgets there ?
-
@dheerendra drawObject is to draw a planet on QGLWidget. This part of code is inserted in paintGL().