• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accuracy of NSThread sleepUntilDate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accuracy of NSThread sleepUntilDate


  • Subject: Re: Accuracy of NSThread sleepUntilDate
  • From: Marcel Weiher <email@hidden>
  • Date: Fri, 3 Aug 2001 16:38:03 +0200

On Friday, August 3, 2001, at 03:03 Uhr, Christian Mike wrote:

I have a multithreaded application in which the threads will sometimes delay
for a short time. I use the code:

NSTimeInterval timeInterval = (NSTimeInterval) someMilliseconds /
1000.0;

[NSThread sleepUntilDate:[NSDate
dateWithTimeIntervalSinceNow:timeInterval]];

Now I am not look for high accuracy here. I realize that when you give up
the processor in a multithreaded application that all bets are off. I am
just looking for some ball park answer about how accurate this delay
mechanism is. What is a reasonably expected quantization unit here?

I have used this mechanism in my Squeak port to MacOS-X, which runs the Squeak interpreter in a secondary thread. I was surprised to find that the NSThread method very often sleeps for exactly the time specified, as short as a couple of milliseconds.

So my recommendation would be to try this method, time it and see if it works for you.

--
Marcel Weiher email@hidden

HOM: <http://www.metaobject.com/downloads/Objective-C/>


  • Prev by Date: Problems with shared libraries...
  • Next by Date: Re: Quick Question
  • Previous by thread: RE: Accuracy of NSThread sleepUntilDate
  • Next by thread: Re: Accuracy of NSThread sleepUntilDate
  • Index(es):
    • Date
    • Thread