主题:【求助!!】关于线程的代码编译不通过
我的代码如下:
#include "stdafx.h"
#include "afxwin.h"
class CMyClass
{
public:
CMyClass();
~CMyClass();
protected:
static UINT MyThread(LPVOID LpP);
BOOL m_bThreadContinue;
UINT m_nThreadCount;
private:
};
CMyClass::CMyClass()
{
m_bThreadContinue = TRUE;
m_nThreadCount = 0;
for (int i=0;i < 100;i++)
{
m_nThreadCount++;
AfxBeginThread( MyThread, this);
}
}
CMyClass::~CMyClass()
{
m_bThreadContinue = FALSE;
while (m_nThreadCount != 0)
Sleep(1);
}
UINT CMyClass::MyThread(LPVOID pParam)
{
CMyClass* pThis = (CMyClass*)pParam;
while (TRUE == pThis->m_bThreadContinue)
Sleep(1);
pThis->m_nThreadCount--;
return 0;
}
int main(int argc, char* argv[])
{
CMyClass aa;
return 0;
}
vc6提示错误:
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/TestThread.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
TestThread.exe - 3 error(s), 0 warning(s)
希望各位高手来帮小弟解决一下
#include "stdafx.h"
#include "afxwin.h"
class CMyClass
{
public:
CMyClass();
~CMyClass();
protected:
static UINT MyThread(LPVOID LpP);
BOOL m_bThreadContinue;
UINT m_nThreadCount;
private:
};
CMyClass::CMyClass()
{
m_bThreadContinue = TRUE;
m_nThreadCount = 0;
for (int i=0;i < 100;i++)
{
m_nThreadCount++;
AfxBeginThread( MyThread, this);
}
}
CMyClass::~CMyClass()
{
m_bThreadContinue = FALSE;
while (m_nThreadCount != 0)
Sleep(1);
}
UINT CMyClass::MyThread(LPVOID pParam)
{
CMyClass* pThis = (CMyClass*)pParam;
while (TRUE == pThis->m_bThreadContinue)
Sleep(1);
pThis->m_nThreadCount--;
return 0;
}
int main(int argc, char* argv[])
{
CMyClass aa;
return 0;
}
vc6提示错误:
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/TestThread.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
TestThread.exe - 3 error(s), 0 warning(s)
希望各位高手来帮小弟解决一下