线程本地存储 [英] Thread local storage
本文介绍了线程本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是存储一些局部变量每个线程的最佳方法是什么?
what is the best way to store some variable local to each thread?
推荐答案
您可以指示静态变量每个线程的存储使用<一个href="http://msdn.microsoft.com/en-us/library/system.threadstaticattribute.aspx"><$c$c>[ThreadStatic]$c$c>属性:
You can indicate that static variables should be stored per-thread using the [ThreadStatic]
attribute:
[ThreadStatic]
private static int foo;
这篇关于线程本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文