What is the difference between ManualResetEvent and AutoResetEvent in .NET?
I have read the documentation on this and I think I understand. An AutoResetEvent
resets when the code passes through event.WaitOne()
, but a ManualResetEvent
does not.
Is this correct?
Yes. It's like the difference between a tollbooth and a door. The ManualResetEvent
is the door, which needs to be closed (reset) manually. The AutoResetEvent
is a tollbooth, allowing one car to go by and automatically closing before the next one can get through.
试想一下, AutoResetEvent
WaitOne()
和Reset()
作为一个原子操作来执行。
The short answer is yes. The most important difference is that an AutoResetEvent will only allow one single waiting thread to continue. A ManualResetEvent on the other hand will keep allowing threads, several at the same time even, to continue until you tell it to stop (Reset it).
链接地址: http://www.djcxy.com/p/29328.html上一篇: 将Java时区强制为GMT / UTC