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

  • SEARCH
  • Home
  • 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 7443029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:16:03+00:00 2026-05-29T11:16:03+00:00

I am working on multi-threading using the following codes in XCode4: #import <Foundation/Foundation.h> bool

  • 0

I am working on multi-threading using the following codes in XCode4:

#import <Foundation/Foundation.h>

bool trigger = false;
NSLock  *theLock=[NSLock new];

@interface Metronome : NSObject
+(void)tick:(id)param;
@end

@implementation Metronome
+(void)tick:(id)param{
while(1)
   {
           NSLog(@"TICK\n");
           usleep(1000000);
           [theLock lock];
           trigger = true;
           [theLock unlock];
   }
}
@end

int main()
{
    [NSThread detachNewThreadSelector:@selector(tick:)
toTarget:[Metronome class] withObject:nil];
}

There is no compiling error, but during execution the console pops up the following warning:

objc[688]: Object 0x100300ff0 of class NSThread autoreleased with no pool
in place - just leaking - break on objc_autoreleaseNoPool() to debug

I’m not familiar with the memory management of obj-C. Can someone explain this to me? Thanks a lot!

  • 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-29T11:16:04+00:00Added an answer on May 29, 2026 at 11:16 am

    you have to create a NSAutoreleasePool for every thread that need invoke autorelease include main thread

    int main()
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        [NSThread detachNewThreadSelector:@selector(tick:)
    toTarget:[Metronome class] withObject:nil];
        [pool release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using net beans for Java development. I'm working on a multi threading application
I am working with multi-dimentioned arrays of bool , int , and various struct
i'm working with a multi-threaded program (using pthreads) that currently create a background thread
i'm trying to get multi tenancy working in my app - using nhibernate integration
I am currently working on a multi branch desktop based project using VB.NET 2008.
I've got a problem with multi-threading - I am working on a framework which
Here's the simplest multi threading example I found so far: import multiprocessing import subprocess
I'm working on a multi-threaded Silverlight application. The application has two threads: Main/UI and
I'm working on a multi-monitor kiosk application that needs to run full-screen on both
I'm working on a multi-lingual WPF project that will be localized into many different

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.