locked
Thread.sleep(4) milliseconds is not working RRS feed

  • Question

  • HI

    i need to make thread to sleep for 4 milli seconds

    thread.sleep(4) is not working in windows 2008 R2 64 bit opearting system with 4GB RAM (it was taking 15 to 16 milliseconds to wake up instead of 4)

    But in some of the machines like windows 7 64 bit with 6 GB ram it was woking as expected, sleeping exactly for 4 seconds

    Can any one help me to fix the issue

    Wednesday, October 9, 2013 6:02 AM

Answers

  • Sleep(Any value less than a time slice) will sleep for a complete time slice on most systems.
    • Proposed as answer by cheong00Editor Wednesday, October 9, 2013 8:13 AM
    • Marked as answer by Eason_H Wednesday, October 16, 2013 2:27 AM
    Wednesday, October 9, 2013 7:58 AM

All replies

  • How did you measure that?

    Keep in mind that you cannot measure time deltas less then 15-16 ms if you used TickCount.


    Josip Habjan      http://habjan.blogspot.com

    Wednesday, October 9, 2013 7:58 AM
  • Sleep(Any value less than a time slice) will sleep for a complete time slice on most systems.
    • Proposed as answer by cheong00Editor Wednesday, October 9, 2013 8:13 AM
    • Marked as answer by Eason_H Wednesday, October 16, 2013 2:27 AM
    Wednesday, October 9, 2013 7:58 AM
  • Hi,

    Unless there is some discrepency in the way how you are evaluating this difference, otherwise I have checked that there is no way that sleep method will have anomaly.

    Wednesday, October 9, 2013 9:38 AM