• 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: infinite loop in another thread destroy g4 CPU
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: infinite loop in another thread destroy g4 CPU


  • Subject: Re: infinite loop in another thread destroy g4 CPU
  • From: Yorh <email@hidden>
  • Date: Wed, 5 Apr 2006 11:46:59 +0200

Hi and thank you to all,

Yes maybe I was drunk :)....
Sorry for stupid question...

Yorh

On 05/apr/06, at 11:08, Robert Tillyard wrote:

There's no mistake, your code is performing the loop as many times as the CPU can, so I'd fully expect it to eat 100% of the CPU.

If you want to do some background task like this I think you need to either add a sleep() in the loop to give other processes a chance to use the CPU or create a thread that is run on a timer to regularly check something.

Regards, Rob.

On 5 Apr 2006, at 08:59, Yorh wrote:

Dear list,

I have a strange problem.
I made a second thread in my app in this way:

[NSThread detachNewThreadSelector:@selector(checkKeepAlive:) toTarget:self withObject:nil];

After it i start an infinite loop (as I usually do) like:

-(void)checkKeepAlive:(id)owner{

	for (; ; ){

	// code
	}
}

But the app eat 76% on a G5 CPU and 100% on G4 and about 85% on Intel core duo....
This is very strange in my thinking because this is a standard loop... and a lot of apps use this strategy in a secondary thread.


Where is the mistake?

Thank you all
Yorh


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >infinite loop in another thread destroy g4 CPU (From: Yorh <email@hidden>)
 >Re: infinite loop in another thread destroy g4 CPU (From: Robert Tillyard <email@hidden>)

  • Prev by Date: Learning about Core Data (was Re: Bindings question for core data application)
  • Next by Date: Re: Tiger Intel AS Studio, eSellerate Integrated to Embedded transition
  • Previous by thread: Re: infinite loop in another thread destroy g4 CPU
  • Next by thread: Re: infinite loop in another thread destroy g4 CPU
  • Index(es):
    • Date
    • Thread