Thread local storage

前端 未结 4 1706
陌清茗
陌清茗 2020-12-08 07:21

what is the best way to store some variable local to each thread?

4条回答
  •  旧巷少年郎
    2020-12-08 07:27

    If you use .Net 4.0 or above, as far as I know, the recommended way is to use System.Threading.ThreadLocal which also gives lazy initialization as a bonus.

提交回复
热议问题