It's generally not a good idea to mess with java threads. If you want to stop a program while running, you should build some safeguards in the code which will allow it to stop prematurely. Something along the lines of
for (..iteration clause..) {
if (shouldStop)
break;
.. do the stuff you're trying to do
}
(Assuming it's a list of things you're processing, there are other techniques to achieve the same for other cases)