相关疑难解决方法(0)

在C#中是bool读/写原子吗?

在C#中访问bool字段原子?特别是,我需要锁定:

class Foo
{
   private bool _bar;

   //... in some function on any thread (or many threads)
   _bar = true;

   //... same for a read
   if (_bar) { ... }
}
Run Code Online (Sandbox Code Playgroud)

.net c# concurrency boolean locking

77
推荐指数
3
解决办法
5万
查看次数

标签 统计

.net ×1

boolean ×1

c# ×1

concurrency ×1

locking ×1