I need to create an application in which the multiplication of two square matrices occurs. In this case, the user is given the opportunity to make a choice of the number of threads in which this multiplication will occur (maxThreadCount = matrixSize).
In this regard, the application has 2 classes:
my_thread : public QObject- the multiplication function is implemented hereMainWindow- GUI
Running threads happens like this:
for (qint32 i=0; i < threads_count; ++i) { myClassArray[i].moveToThread(&thrArray[i]); thrArray[i].start(); QObject::connect(&thrArray[i], SIGNAL(started()), &myClassArray[i], SLOT(calculatingFirstAndLastIndeces())); } Where, after multiplication in the class my_thread , a signal is sent to end the multiplication:
emit end_work(numberThisThread); But processing:
void MainWindow::rcvEndWork(qint32 threadNumber) { thrArray[threadNumber].quit(); qDebug() << "Threads №" << threadNumber << " were closed"; } This signal in the MainWindow occurs only once, i.e. if the signal is sent from 1600 streams, only one will close.
How can I close all threads after they have finished their work?
#pragma omp parallel foreasier? - Bearded Beaver