线程本地存储 [英] Thread local storage

查看:119
本文介绍了线程本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是存储一些局部变量每个线程的最佳方法是什么?

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]属性:

You can indicate that static variables should be stored per-thread using the [ThreadStatic] attribute:

[ThreadStatic]
private static int foo;

这篇关于线程本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆