TMutex delphi的WaitFor函数与win32 API中的等效函数之间的区别 [英] Difference between the WaitFor function for TMutex delphi and the equivalent in win32 API

查看:191
本文介绍了TMutex delphi的WaitFor函数与win32 API中的等效函数之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

delphi的文档说TMutex和其他同步对象的WaitFor函数要等到信号到一个对象的句柄时才出现,但是这个函数还可以保证调用者拥有该对象的所有权吗?

The documentation of delphi says that the WaitFor function for TMutex and others sychronization objects wait until a handle of object is signaled.But this function also guarantee the ownership of the object for the caller?

推荐答案

是的, TMutex 的调用线程拥有互斥锁;该类只是OS互斥对象的包装。通过检查 SyncObjs.pas 自己查看。

Yes, the calling thread of a TMutex owns the mutex; the class is just a wrapper for the OS mutex object. See for yourself by inspecting SyncObjs.pas.

对于其他同步对象,例如 TCriticalSection,情况并非如此。 。我在该对象上调用的任何线程 Release 方法,而不仅仅是调用 Acquire 的线程。

The same is not true for other synchronization objects, such as TCriticalSection. Any thread my call the Release method on such an object, not just the thread that called Acquire.

这篇关于TMutex delphi的WaitFor函数与win32 API中的等效函数之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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