创建线程被警告
我在程序多线程程序中创建线程时,BoundsChecker给了我如下警告:
*********************************************************************
Description:
A thread, which makes calls to one or more run-time library functions, was created using CreateThread. A thread that uses functions from the C run-time libraries should use the _beginthread and _endthread C run-time functions for thread management rather than CreateThread and ExitThread. Failure to do so results in small memory leaks when ExitThread is called.
Note:
If the run-time library is statically linked and the module lacks debug info, it may not be possible for the call to _beginthread to be detected and this error is reported. In this situation, the error can be safely suppressed.
Sample Code:
...
DWORD WINAPI aThread(void *arg)
{
char *a = malloc (10);
free (a);
ExitThread(0);
}
void main()
{
int i;
DWORD id;
HANDLE hThread2[NUM_THREAD];
for (i = 0; i < NUM_THREAD; i++)
{
hThread2[i] = CreateThread(NULL, 0, aThread, NULL, 0, &id);
}
WaitForMultipleObjects(NUM_THREAD, hThread2, TRUE, INFINITE);
for (i = 0; i < NUM_THREAD; i++)
{
CloseHandle(hThread2[i]);
}
}
...
Repair
Use the C run-time functions _beginthread and _endthread to create and destroy threads, which use functions from the C run-time libraries.
*********************************************************************
我用的是::AfxBeginThread()函数创建线程的,请问上面的Description是什么意思?