是否有Java的&QUOT之间的差异;同步"和C#的"锁定"?
问题描述:
做这两个关键字有相同的效果,或者是有什么我应该知道的?
Do these two keywords have exactly the same effect, or is there something I should be aware of?
答
据这个网站:http://en.csharp-online.net/CSharp_FAQ:_What_is_the_difference_between_CSharp_lock_and_Java_synchronized, C#锁定
和Java 同步
code块是语义上相同,而对于方法,Java使用同步
,而C#使用一个属性: [MethodImpl(MethodImplOptions.Synchronized)]
According to this site: http://en.csharp-online.net/CSharp_FAQ:_What_is_the_difference_between_CSharp_lock_and_Java_synchronized, C# lock
and Java synchronized
code blocks are "semantically identical", while for methods, Java uses synchronized
while C# uses an attribute: [MethodImpl(MethodImplOptions.Synchronized)]
.