gpt4 book ai didi

.net - MethodImplOptions.Synchronized 的作用是什么?

转载 作者:行者123 更新时间:2023-12-03 05:57:12 26 4
gpt4 key购买 nike

MethodImplOptions.Synchronized 的作用是什么?

下面是代码

[MethodImpl(MethodImplOptions.Synchronized)]
public void Method()
{
MethodImpl();
}

相当于

public void Method()
{
lock(this)
{
MethodImpl();
}
}

最佳答案

Mr. Jon Skeet 回答了这个问题在另一个site .

引自帖子

It's the equivalent to putting lock(this) round the whole method call.

该帖子有更多示例代码。

关于.net - MethodImplOptions.Synchronized 的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2223656/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com