configuration:debug result: program exit with code 0.
configuration:release result: main thread infinite loops,wont jump out of the loop(t.n==0 is true).
how can I get out of the loop ?
Only one writer thread,so I didnot use any mutex.
qt5.13 vs2017
main.cpp:
//#include"QtTestProg.h"
#include<QApplication>
#include<QMessageBox>
#include<QThread>
class MyThread :public QThread
{
Q_OBJECT
public:
int n = 0, m = 1;
void run()override;
};
void MyThread::run()
{
for (; m;) {
QThread::msleep(3000);
n = 1;
}
}
int main(int argc, char*argv[])
{
QApplication a(argc, argv);
MyThread t;
t.start();
for (; 1;)
{
if (t.n != 0)
{
break;
}
}
t.m = 0;
t.quit();
t.wait();
return 0;
}
#include"main.moc"