是静态的类线程安全 [英] Are Static classes thread safe

查看:102
本文介绍了是静态的类线程安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经经历了它写在所有的静态类是线程安全的MSDN走了。那么这篇文章是为1.1版本...

I have gone through msdn where it is written that all the static classes are thread safe. Well that article is meant for version 1.1...

http://msdn.microsoft.com /en-us/library/d11h6832(v=vs.71).aspx

所有公共静态成员(方法,属性,字段和事件)内内的多线程环境中的.NET Framework的支持并发访问。因此,任何.NET框架的静态成员可以同时从两个线程调用,而不会遇到竞争条件,死锁,或崩溃。

All public static members (methods, properties, fields, and events) within the .NET Framework support concurrent access within a multithreaded environment. Therefore, any .NET Framework static member can be simultaneously invoked from two threads without encountering race conditions, deadlocks, or crashes.

推荐答案

没有,它不说,静态类是线程安全的,它说,公共静态成员是线程安全的。

No, it doesn't say that static classes are thread safe, it says that public static members are thread safe.

有关静态方法,例如,这意味着,他们只使用数据,您在发送作为参数,或其他静态成员也线程安全

For static methods for example, this means that they only use the data that you send in as parameters, or other static members that are also thread safe.

您不必同步调用静态方法,除非它的需要来保护您发送给方法的数据。

You don't have to synchronise calls to static methods, unless it's needed to protect the data that you send into the method.

这篇关于是静态的类线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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