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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:26:28+00:00 2026-06-13T16:26:28+00:00

I am actually looking for an easier way to kill the thread not matter

  • 0

I am actually looking for an easier way to kill the thread not matter where the thread is running at. But most of the solutions in internet point me to use boolean flag to control the execution of the thread, if I want to stop the thread then set the boolean variable to false.

But what if the task that in the runnable is a LONG linear task, which mean the task is not repeating? In that case, it is not so easy to create a ‘while’ loop to cover the whole block of task.

It is really so temptative to use Thread.stop but the warning “Deprecated” seem like quite dangerous to use. I have read through this article
Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated?

but I can’t understand

If any of the objects previously protected by these monitors were in
an inconsistent state, other threads may now view these objects in an
inconsistent state. Such objects are said to be damaged.

What does the “inconsistent state” mean? I appreciate if anyone can explain about this.

I want to extend my question to a more lower level of view, let say i = i + 1; in JVM (perhaps assembly language alike), maybe this Java statement will be split into few smaller instructions, for example like move i ; add i ; get i into memory 0x0101 (This is an example! I totally don’t know assembly language!)

Now, if we call thread.stop, where actually will it stop at? Will the thread stop after a COMPLETED Java statement, or could be in the middle of the “assemble language”? If the answer is the second, could it be reason that we said

Such objects are said to be damaged.

?

Ok, my question is kind of confused, hope someone can understand and explain. Thanks in advance.

  • 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-06-13T16:26:29+00:00Added an answer on June 13, 2026 at 4:26 pm

    The “inconsistent state” means state of data as your application cares about, state that your application logic have carefully produced by making your application thread-safe with locks/monitors etc.

    Imagine you have this simple method:

    public synchronized void doSomething() 
    {
          count++;
          average = count/total;
    }
    

    This method, along with other methods are synchronized, as multiple threads are using this object.
    Perhaps there’s a

    public synchronized AverageAndCount getMeasurement() 
    {
       return new AverageAndCount(average, count);
    }
    

    This assures that a thread can’t read an incomplete measurement, i.e. if the current measurement is in the process of being calculated inside e.g. doSomething(), getMeasurement() will block/wait until that’s finished.

    Now, imagine the doSomething is run in a thread, and you call .stop() on that thread.

    So the thread might be stopped right after it performs count++;, the monitor that’s held is unlocked and the method terminates and average = count/total; is not executed,

    That means the data is now inconsistent. Anyone calling getMeasurement() afterwards will now get inconsistent data.

    Note also that at this point it is not very relevant whether this happens at a java statement level, or at a lower level, the data can be in an inconsistent state that you can’t reason about in any case.

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

Sidebar

Related Questions

I'm not looking to create custom error pages, but to actually issue error messages
I'm actually looking for how to use Amazon SES on phpbb3. I tried to
What's the best way to use <input type=radio> in HTML? I'm looking for HTML
I'm looking for a way to make a grid (for now using Table, but
I'm looking for the most pythonic way to implement a version of the list
I know that the title doesn't really say what I'm actually looking for, as
Actually I'm looking for a jQuery plug-in that can handle this: there is a
Actually I am working on this for the last 3 or 4 weeks but
I'm looking to create a very small cataloguing app for personal use (although I'd
I am looking for the best way to get a field value from a

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.