• 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: thread spinning ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: thread spinning ...


  • Subject: Re: thread spinning ...
  • From: Chris Suter <email@hidden>
  • Date: Wed, 6 Dec 2006 15:28:01 +1100

I believe runMode:beforeDate can return immediately when there are no input sources.

I'll bet it's returning NO.

- Chris

On 06/12/2006, at 3:21 PM, Martin Redington wrote:


Please remind me never to do any multi-threaded programming again.

I have a loop that drives my worker thread, that looks something like the code below. Recently, I've observed one of these threads (occasionally more, but usually just one), "spinning" in this loop, and consuming a lot of CPU. I'm pretty certain that at the time, the thread is not receiving any messages, just waiting around to be reaped. Normally, this code runs without incident.

// threadRunning is a utility method that checks the threadDictionary to see if a flag has been set.
// it is only set or accessed from within the current thread.


while ([self threadRunning])
{
NSDate *newDate = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.50];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:newDate];
[newDate release];
}



Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: thread spinning ...
      • From: Martin Redington <email@hidden>
References: 
 >thread spinning ... (From: Martin Redington <email@hidden>)

  • Prev by Date: thread spinning ...
  • Next by Date: Re: Framework for displaying Trees graphically?
  • Previous by thread: thread spinning ...
  • Next by thread: Re: thread spinning ...
  • Index(es):
    • Date
    • Thread