本文介绍了在ReleaseMutex之前,互斥对象上的CloseHandle-会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在线程完成互斥锁之前,我在互斥锁上调用CloseHandle,因此尚未调用ReleaseMutex,那么预期的行为是什么?

If I call CloseHandle on a mutex before a thread has finished with the mutex, and hence, hasn't yet called ReleaseMutex, what is the expected behaviour?

推荐答案

最严重的后果是正在等待互斥体被解除阻塞的线程. WaitXxx调用返回WAIT_ABANDONED.此时,调用TerminateProcess将是一个非常好的主意,因为您不知道到底发生了什么.

The most serious consequence is a thread that's waiting for the mutex getting unblocked. The WaitXxx call returns WAIT_ABANDONED. At which point it would be a really good idea to call TerminateProcess because you have no idea what the hell just happened.

这篇关于在ReleaseMutex之前,互斥对象上的CloseHandle-会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:43