Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:46:08+00:00 2026-05-26T09:46:08+00:00

I have a strange situation where a while loop is causing my cpu usage

  • 0

I have a strange situation where a while loop is causing my cpu usage to go to between 90 and 100%. The cpu stays this high.
If I comment out the while loop the cpu remains normal.

Whats going wrong here?

I’ve put in a breakpoint and the while loop definitely does exit.

[self performSelectorInBackground:@selector(checkstate:) withObject:padid];



-(void)checkstate:(PadIDSIdentifier*)pids
    {

        int pid=0;
        int cid=0;
        pid=pids.padid;
        cid=pids.channelid;


        NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];


        while (change==NO) 
        {

         // wait for the condition I want
         change=YES;




        }



        [pool release];

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:46:08+00:00Added an answer on May 26, 2026 at 9:46 am

    You’re eating up the CPU in that loop. What you need to do is let the OS wait for you (which sets the wait process on low-priority so it occurs in idle time).

    How you do that in Windows is WaitForSingleObject. How you do that on iPhone is with NSCondition.

    Here is link: How do I use NSConditionLock? Or NSCondition

    Basically, the NSCondition is signaled by the other thread, allowing your thread to resume processing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange situation in one view controller where this line crashes in
Hi I have a strange situation here: # Is there a semantic difference between
I guess this is strange situation. I have a results table which contain 100k
I'm experiencing this strange situation. I have a UITableView where, when the user selects
I have a very strange situation. I have a large set of records to
I have this strange call stack and I am stumped to understand why. It
I have this strange issue with my web app. You see, I'm using jQuery
I am new to VB.net and facing a strange situation. I have a structure
i have a strange situation may its a easy fix or something i may
We have a strange situation where we lose a Stateless SessionBean in a Bean

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.