Java的“同步"和“同步"之间有什么区别吗?和 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# lock
和 Java synchronized
代码块语义相同",而对于方法,Java 使用 synchronized
而 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)]
.
相关文章