Sha*_*lle 10 multithreading thread-static thread-safety
[ThreadStatic] private static Foo _foo; public static Foo CurrentFoo { get { if (_foo == null) { _foo = new Foo(); } return _foo; } }
以前的代码线程安全吗?或者我们需要锁定方法吗?
小智 15
如果它的ThreadStatic每个线程有一个副本.因此,根据定义,它的线程安全.
这篇博客在ThreadStatic上有一些很好的信息.
归档时间:
17 年,2 月 前
查看次数:
2396 次
最近记录: