I apologize in advance if this question sounds presumptuous. I'm fairly new to this. So here it goes . . .
I've been researching the "java thread stopping" issue for a while. I read many articles on stackoverflow, and most of them come to a conclusion that thread stopping is very awkward in java. Some good ways include:
- Using
join
(this answer got 87 upvotes) and wait until a thread finished. - Set a
volatile
flag to signal the other threads. This answer got 113 upvotes - Many recommend
Thread.interrupt()
and later checkisInterrupted
- Some recommend using a high level API like ExecutorService. But that
shutdownNow
method does not give any guarantees, and counts on thatisInterrupted
boolean
But neither of the above methods allow an immediate thread stop. For example, if a program is running some SQL
and waiting for an external database respond, then ALL of the above method will "humbly wait" until that SQL
finishes. So the stopping is NOT immediate at all. Only when that SQL
finishes (which may take hours), will the program check for isInterrupted
or other flag, and then stop
Here is the punchline . . .
I know Eclipse is written in java
according to this stackoverflow answer. And whenever I click that red stop button , Eclipse will stop my application immediately. I presume it is NOT using Thread.stop
since it's deprecated. But I it can't possible be using those method recommended on stackoverflow. How does Eclipse manage to stop threads so fast?