I am not very much aware of Multithreading but I am using like this.
QHash<unsigned long, DOSDIR*>newHash = OldHash;
OldHash.clear();
MyThread myThread;
myThread.NewThreadToFree(newHash);
QHash<unsigned long, DOSDIR*>newHash = OldHash;
OldHash.clear();
MyThread myThread;
myThread.NewThreadToFree(newHash);
To copy to clipboard, switch view to plain text mode
Thread Class:
{
Q_OBJECT
public:
NewThreadToFree();
void run();
private:
QHash<unsigned long, DOSDIR*>MyHash;
};
class MyThread:public QThread
{
Q_OBJECT
public:
MyTHread(QObject *parent = 0);
NewThreadToFree();
void run();
private:
QHash<unsigned long, DOSDIR*>MyHash;
};
To copy to clipboard, switch view to plain text mode
... receiving the newHash in a myHash ////
void MyThread::NewThreadToFree()
{
///start the thread
}
void MyThread::run()
{
qDeleteAll(myHash);
}
void MyThread::NewThreadToFree()
{
///start the thread
}
void MyThread::run()
{
qDeleteAll(myHash);
}
To copy to clipboard, switch view to plain text mode
It is again look like hanging (although it is running) ,but due to the large item in the QHash
qDeleteAll is taking long time to clear the memory.
Bookmarks