Maybe I'm not using threads correctly.. Here's my code:
for(int i = 0; i < numCores; i++)
{
new MyThread(...);
}
for(int i = 0; i < numCores; i++)
{
new MyThread(...);
}
To copy to clipboard, switch view to plain text mode
The class MyThread is:
//HEADER
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
{
public:
MyThread(...);
protected:
void run();
};
#endif // MYTHREAD_H
// BODY
#include "mythread.h"
MyThread::MyThread(...)
{
start();
}
void MyThread::run()
{
...
}
//HEADER
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
class MyThread : public QThread
{
public:
MyThread(...);
protected:
void run();
};
#endif // MYTHREAD_H
// BODY
#include "mythread.h"
MyThread::MyThread(...)
{
start();
}
void MyThread::run()
{
...
}
To copy to clipboard, switch view to plain text mode
Is it right? Have I to call exec() in the run() method? If yes, where?
Thanks,
Dario
Bookmarks