Questions tagged «spinwait»

3
为什么.NET内部Hashtable中有Thread.Sleep(1)?
最近,我在阅读.NET Hashtable的实现,遇到了我不理解的代码。部分代码是: int num3 = 0; int num4; do { num4 = this.version; bucket = bucketArray[index]; if (++num3 % 8 == 0) Thread.Sleep(1); } while (this.isWriterInProgress || num4 != this.version); 整个代码是内public virtual object this[object key]的System.Collections.Hashtable(mscorlib程序版本= 4.0.0.0)。 问题是: 在Thread.Sleep(1)那里的原因是什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.