• 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: CPU utilization in Snow Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CPU utilization in Snow Leopard


  • Subject: Re: CPU utilization in Snow Leopard
  • From: Graham Cox <email@hidden>
  • Date: Tue, 20 Oct 2009 17:41:18 +1100


On 20/10/2009, at 5:28 PM, Shashanka L wrote:

-(void)newThread
{
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];


//Some operations...


do //Keeps thread alive till date
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow: 0.1]];


	} while (mShouldThreadAlive); //Waiting for other process to complete

  [pool release];

}


Mind you, having said what I just said, this is a bad approach anyway. You should not "keep a thread alive" until it gets some flag, that's just wasting CPU time doing nothing but spinning. Instead the thread should sleep until it has something to do. If you need to wait for another thread to finish, use a NSConditionLock to do it properly. Also, if this code is representative, you are spinning it after all the processing has finished, which is pointless. Just let it terminate if it has nothing more to do.

--Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: CPU utilization in Snow Leopard
      • From: Alastair Houghton <email@hidden>
References: 
 >Re: CPU utilization in Snow Leopard (From: Shashanka L <email@hidden>)

  • Prev by Date: Re: CPU utilization in Snow Leopard
  • Next by Date: Re: GC Basic questions
  • Previous by thread: Re: CPU utilization in Snow Leopard
  • Next by thread: Re: CPU utilization in Snow Leopard
  • Index(es):
    • Date
    • Thread