是静态的类线程安全线程、静态、安全

2023-09-04 00:20:28 作者:习惯那些不曾习惯的习惯

我已经经历了它写在所有的静态类是线程安全的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.