我可以在_beginthreadex()成功后立即调用CloseHandle()? [英] Can I call CloseHandle() immediately after _beginthreadex() succeeded?

查看:809
本文介绍了我可以在_beginthreadex()成功后立即调用CloseHandle()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不感兴趣使用从 _beginthreadex()返回的句柄。是否可以立即调用 CloseHandle()

I'm not interested in using the handle returned from _beginthreadex(). Is it safe to call CloseHandle() on it immediately?

我相信这必须做,以避免内存泄漏。

I believe this must be done to avoid memory leaks.

推荐答案

是的,您可以在决定不再需要该句柄时立即关闭句柄。这不会影响线程执行。但是,您可能应该先检查线程是否已经启动,然后再继续。

Yes, you can close the handle as soon as you decide you no longer need that handle. That won't affect thread execution. However you likely should check whether the thread has been started at all before you proceed.

您担心的泄漏不是内存 ,它们是系统资源泄漏 - 通常它们更糟。

The leaks you're concerned about are not memory leaks, they are system resources leaks - usually they are much worse.

这篇关于我可以在_beginthreadex()成功后立即调用CloseHandle()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆