锁,监视器,互斥 [英] Lock,Monitor,Mutex

查看:136
本文介绍了锁,监视器,互斥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
监控VS互斥锁在C#

在这个网站,我发现从不同的人,这使得不同的混淆不同的答案。还是根本就不清楚究竟哪些情况下每三个方面[锁定,显示器,互斥]的将是实时需求非常有用的。
,使这些条款之间更加混乱。

In this site i found different different answers from different people which makes confusing. still not at all clear exactly on which scenario each of the three terms [Lock,Monitor,Mutex] will be very useful for the realtime need. Makes much more confusion between these terms.

我需要在高水平,在深度和广度上非常明显的差异实质上是要求每个中使用三个学期有更好的例子和清晰的认识。

I would require very clear differences in High level-in depth and which is essentially required to use among each of the three terms with better example and with clear understanding.

请提供在非常高的水平实时使用情况的信息或需要使用C#.NET具有非常好的例子。

Kindly provide the info at the very high level of realtime usage or need using C#.NET with very good example.

由于
Sukumar

Thanks Sukumar

推荐答案

简体中文,简称:

A 显示器是管理.NET同步原语(范围只有一个应用程序域)。 C#的锁()什么也不做,但使用显示器尝试......最后子句,以确保该锁是在异常的情况下释放。

A Monitor is the managed .NET synchronization primitive (scope is one application domain only). The C# lock() does nothing but use Monitor and a try...finally clause to make sure that the lock is released in the case of an exception.

一个互斥是一个OS同步对象,这也可以使用跨多个进程(通过命名的互斥体)同步。

A Mutex is an OS synchronization object, which can also be used to synchronize across multiple processes (via named mutex).

这篇关于锁,监视器,互斥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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