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

The Archive Base Latest Questions

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

I am using a thread to update messages in background in my application. The

  • 0

I am using a thread to update messages in background in my application. The thread is started in my messages class.

Messages.m

timerThread = [[NSThread alloc] initWithTarget:self
                selector:@selector(startTimerThread:) object:nil]; 
[timerThread start];

now I want the thread to stop when the user signout of the application. For that in the signout method (in another class) I added

Messages *msg=[[Messages alloc]init];  
[msg.timerThread cancel];  
[msg release];  

But even after signing out of the application the thread is still running.

  • 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-20T09:33:08+00:00Added an answer on May 20, 2026 at 9:33 am

    ( I am assuming here that you create an instance of Messages somewhere else in the program )

    According to your provided code you are creating a new Messages instance as part of your sign out process ( which starts a new thread ), canceling that new thread ( -cancel is a proper way to stop a thread — if your thread method follows the considerations listed in the documentation ), then releasing your ( extra? ) Messages instance. At this point your original Messages instance is still around, and the thread from that is still running.

    If you want the thread to stop when the instance of the class is deallocated, you probably should take care of that in a -dealloc method on Messages and make sure your original Messages instance is released at the proper time.

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

Sidebar

Related Questions

i am using a java thread to update jlabel text value in my application
I am using thread which will receive messages from the external application.So my thread
The application I'm working on is using a background thread to download a list
I am using a NSProgressIndicator in my main thread to update on progress as
I have a background thread listening to network, using a callback to process and
I have an application that logs messages to the screen using a TextBox. The
View model is loading data asynchronously using background worker thread in model. All properties
I have a BackgroundWorker thread that is posting messages, using BeginInvoke on a textbox
I am creating 5 thread here using ThrdFunc. Here each thread update the listBox.
I have a background thread (NSOperation) that I use to get new messages for

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.