There are good reasons for not using Thread.stop()
, so how about a different approach: Instead of running the analysis in a separate thread, try running it as a separate program.
It'll mean a small performance hit, but pragmatically, task creation and serializing/deserializing the results shouldn't have a measurable effect compared to the scale of your current timing.
Unlike Thread.stop()
, killing a program results in a clean exit since the jvm exits.
The downside to this is that the answers to your followup questions ("how do I start a task from within a java program", "how do I wait for the completion of another program", and "how do I programmatically kill another program") are all specific to operating system.
The upside is that they're already answered: