Mikan
August 23rd, 2010, 04:48 PM
I'm testing my framework to work with threads, so I'm creating several threads, deleting them, creating again... and eventually I have this error:
Free Heap block XXXX modified at XXXX after it was freed.
I'm using the CWinThread class, and creating the threads in this way:
std::vector<CWorkerThread*> m_vThreads;
for (int nThreads = 0; nThreads<nNumThreads; nThreads++)
{
m_vThreads.push_back(new CWorkerThread(nThreads));
m_vThreads[nThreads]->CreateThread();
}
and deleting like this:
for (unsigned int nIndex = 0; nIndex<m_vThreads.size(); nIndex++)
{
delete m_vThreads[nIndex];
m_vThreads[nIndex] = NULL;
}
m_vThreads.clear();
CWorkerThread()
{
AfxBeginThread(Run, this, 0, NULL, CREATE_SUSPENDED, 0);
}
and in the destructor, I terminate the threads awakening them and returning 0.
Any suggestion of what can be the problem?
Thanks!
Mikan
Free Heap block XXXX modified at XXXX after it was freed.
I'm using the CWinThread class, and creating the threads in this way:
std::vector<CWorkerThread*> m_vThreads;
for (int nThreads = 0; nThreads<nNumThreads; nThreads++)
{
m_vThreads.push_back(new CWorkerThread(nThreads));
m_vThreads[nThreads]->CreateThread();
}
and deleting like this:
for (unsigned int nIndex = 0; nIndex<m_vThreads.size(); nIndex++)
{
delete m_vThreads[nIndex];
m_vThreads[nIndex] = NULL;
}
m_vThreads.clear();
CWorkerThread()
{
AfxBeginThread(Run, this, 0, NULL, CREATE_SUSPENDED, 0);
}
and in the destructor, I terminate the threads awakening them and returning 0.
Any suggestion of what can be the problem?
Thanks!
Mikan