创建线程被警告

zhangjj2 zhangjj2 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在程序多线程程序中创建线程时,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是什么意思?
...全文

相关推荐

警告效果服务案例源码.zip

这是一款警告效果服务案例源码,该案例是以一个闹钟的警告效果的,效果的源码也比较容易学习和使用,经常使用于闹钟管理等操作,非常适合一些新手的使用与学习。  

weixin_39840515

100行Java代码构建一个线程池

100行Java代码构建一个线程池

chenroujie

fluffyThreadPool:Java中的另一个线程池实现

蓬松的线程池 警告:未完成。 可能包含错误。 Java中的另一个线程池实现。 该线程池将创建给定数量的工作线程并将它们全部空闲。 可以将任务作为可运行对象分配给池。 如果有一个空闲的工作程序,它将立即执行可运行程序。 如果不是,则将可运行对象添加到队列中,并且每次线程进入空闲状态时,此线程都会处理队列中最旧的元素。 这是一个非常简单的(或愚蠢的...)调度算法。 一个更复杂,更有效的调度系统将在以后添加到项目中。 示例代码: /* Constructor needs max Number of Threads and PrintStream to print messages to (or null). */ Pool pool = new Pool ( 1 , System . out); Runnable exampleRun = new Runnable () { @O

看不见的天边

《Programming Server side Application for Microsoft Windows2000》代码

如何编写WINDOWS2000下的系统服务?请看Jeffery Richter编写的《Programming Server side Application for Microsoft Windows2000》,这里给出随书附带的源代码示例,定能给你帮助。

yanghongkun

多线程计数实现多线程执行后再执行主线程

多线程计数实现多线程执行后再执行主线程,在项目中实际应用。

杨健的博客
评论 2
收藏 已收藏
分享
返回顶部
zhangjj2
进程/线程/DLL 15,466 成员 49,169 内容