void MyThread1::run(){//exec(); qDebug() << "Starting first thread";QTime myTime; std::string aString; myTime.start(); for (int i = 0; i < 20000; ++i) { aString += "New test value"; } const char *aValue = aString.c_str(); for (int i = 0; i < strlen(aValue); ++i) { //dummy }double myMlsec = myTime.elapsed(); myMlsec /= 1000;qDebug() << "First thread run time: " << myMlsec; //qDebug() << "First run"; connect(this, SIGNAL(finished()), this, SLOT(FinishProc1()));exec(); //запускаем обработку очереди сообщений потока}
QTime myTime; std::string aString; myTime.start(); for (int i = 0; i < 20000; ++i) { aString += "New test value"; } const char *aValue = aString.c_str(); for (int i = 0; i < strlen(aValue); ++i) { //dummy }double myMlsec = myTime.elapsed(); myMlsec /= 1000;qDebug() << "No multithreading, only one CPU is working for " myMlsec;
QThread *MyThread11 = new MyThread1(); MyThread11->start(); QThread *MyThread22 = new MyThread2(); MyThread22->start(); qDebug() << "Complete" << endl;