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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:07:38+00:00 2026-05-31T11:07:38+00:00

I have one thread class which star in onCreate of an activity. class MyThread

  • 0

I have one thread class which star in onCreate of an activity.

 class MyThread extends Thread
 {
      void run()
      {
           //My code which takes time.
      }
 }

 //-------------------------- To run the thread
 MyThread mThread = new MyThread();
 mThread.start();

On some external events i need to stop/destroy currently running thread.
And Then i create a new copy of MyThread and call start function on the new thread to run it.

But i am not able to destroy/stop the previous running thread.
Is there any API by which we can destroy running thread.

  • 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-31T11:07:39+00:00Added an answer on May 31, 2026 at 11:07 am

    you cannot destroy…only the android will stop the thread when requires.. you cannot stop or destroy it.. instead try like this..

    class MyThread extends Thread
     {
      void run()
      {
     while(bool){
           //My code which takes time.
      }
     }
     }
    

    //————————– To run the thread

       MyThread mThread = new MyThread();
       mThread.start();
    

    now when u want to stop the thread… change bool value to false

    bool=false;
    

    now your code doesnt run… and you can start new thread…

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

Sidebar

Related Questions

Let's say that I have the following code that's run in one thread of
In my code, I have a class which create a new thread. This new
I have a Java class called CreateThread which creates one thread, everytime an object
I have a multi-threaded application written in Python in which one thread takes care
I have class A and classes B and C. class B runs one thread
I have one std::list<> container and these threads: One writer thread which adds elements
I am writing code in VS2005 using its STL. I have one UI thread
I have one 'main' thread that creates an array of objects of class SlowData
I have a class which is being operated on by two functions. One function
I need to have two classes, one class has two methods each of which

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.