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 5945475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:41:12+00:00 2026-05-22T16:41:12+00:00

I was trying out a sample thread program from google and i am getting

  • 0

I was trying out a sample thread program from google and i am getting a runtime exception.

Is there any website that gives an example of how to use runloops along with threads.
I need to set two events and spawn a thread and to do another function parallely.

// Runner.m

#import "Runner.h"

@implementation Runner

    - (void)rumMe:(id)ignored {

        NSLog(@"Running with threads!!");
    }

@end

// Runner.h

@interface Runner : NSObject

    -(void)rumMe:(id)ignored;

@end

// Thread1.m

#import <Foundation/Foundation.h>
#import "Runner.h"

int main (int argc, const char * argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    Runner* runner = [Runner new]; 
    [NSThread detachNewThreadSelector:@selector(runMe:) toTarget:runner withObject:nil];
    [pool drain];
    return 0;
}

Runtime Exception:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** 
-[NSThread initWithTarget:selector:object:]: target does not implement selector (*** 
-[Runner runMe:])'
  • 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-22T16:41:13+00:00Added an answer on May 22, 2026 at 4:41 pm

    First part: you had a typo

    // method declaration
    rumMe:   with an _m_
    // call
    runMe:   with an _n_
    

    Second part: your main function is returning and causing the program to exit before you have given the thread a chance to do anything. In this simple simple example, you could simply

    sleep(2);
    

    right after the call to detachNewThreadSelector:

    In more complex cases, you might need to make a call to CFRunLoopRun(); on the main thread, or take other action to keep the second thread alive.

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

Sidebar

Related Questions

I was trying out a code sample from this book that should demonstrate that
I am trying to work out a code sample to demonstrate the debugging functionality
I'm trying to figure out how to generate a simple join that uses an
I'm just starting out writing trying to write a simple program in C and
i just started learning swings. And thought of trying out a simple program, but
I am trying to run a sample application from HttpClient 4.0.1. It is the
I'm trying to get console input in my Clojure program, but when it gives
i'm trying to record an audio sample with AudioRecord. I've used a thread to
This is my first time working with Quartz. I am trying out a sample
I'm trying to write very simple program which will imitate simple DeadLock, where Thread

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.