hello, in fact this code is also not working:
Thread wThread; // a simple subclass of QThread
for (uint y=0;y<500;y++){
bool assigned = false;
while(!assigned) {
if (!wThread.isRunning()){
wThread.start(); // job done from the other thread. Just solve a simple linear programming problem (glpk documentation example)
assigned = true;
break;
}
}
}
Thread wThread; // a simple subclass of QThread
for (uint y=0;y<500;y++){
bool assigned = false;
while(!assigned) {
if (!wThread.isRunning()){
wThread.start(); // job done from the other thread. Just solve a simple linear programming problem (glpk documentation example)
assigned = true;
break;
}
}
}
To copy to clipboard, switch view to plain text mode
The idea is to have a vector of threads doing the jobs simultaneously and for doing this I will need a patched version of the glpk library, but I stopped when I noticed that even when I use a single thread I have problems.
Then I tried to put the example on its minimum terms.
The Thread::run() function just does something like:
for (uint i=0;i<3;i++){
glp_prob *lp;
lp = glp_create_prob();
[...]
glp_load_matrix(lp, 9, ia, ja, ar);
glp_simplex(lp, NULL);
[...]
glp_delete_prob(lp);
}
for (uint i=0;i<3;i++){
glp_prob *lp;
lp = glp_create_prob();
[...]
glp_load_matrix(lp, 9, ia, ja, ar);
glp_simplex(lp, NULL);
[...]
glp_delete_prob(lp);
}
To copy to clipboard, switch view to plain text mode
This code works if I call it directly in the main thread (that really in the real application is itself a working thread separated from the GUI), but crash when called from wThread. I thought that even if the bug report refers to the "wait()" function, the cause underlying it would be the same causing the problem in my situation.
Bookmarks