一个变量谁的值跨线程读不被视为重要 [英] Cross thread reading of a variable who's value is not considered important
问题描述
在C#,是否有更新的变量(不使用锁定),其中多个线程可以读取的值的一种方式,但该更新了变量线程不被视为重要的。
In c#, is there a way of updating a variable (without using lock) where multiple threads can read the value, but the thread that updates the variable is not considered important.
我的意思是,如果看重,但一个线程更新的其他线程没有得到更新值几分钟后,然后就是确定。
What I mean is, if a thread updates that value but the other threads don't get that updated value a few minutes later then that is OK.
有没有这样一种方式?
非常感谢
推荐答案
最好的一种选择是使用一个 ReaderWriterLockSlim 的(或一<一HREF =http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlock.aspx相对=nofollow> ReaderWriterLock 如果你不使用.NET 3.5)。提示:本教程应该让你开始
The best option is to use a ReaderWriterLockSlim (or a ReaderWriterLock if you're not using .net 3.5). Tip: This tutorial should get you started.
这篇关于一个变量谁的值跨线程读不被视为重要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!