Questions tagged «thread-sleep»

7
如何延迟Java?
我正在尝试用Java做某事,而我需要一些在while循环中等待/延迟几秒钟的时间。 while (true) { if (i == 3) { i = 0; } ceva[i].setSelected(true); // I need to wait here ceva[i].setSelected(false); // I need to wait here i++; } 我想构建一个步进音序器,并且对Java还是陌生的。有什么建议么?
342 java  wait  sleep  thread-sleep 

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.