I've written a continuesly running thread program in Java using runnable implenetation approach. Now, since its a continuously running program, I've a while(true) loop in run method. Now, my question is how do I halt this program if I want to stop running it. I do not want to use "kill" command. I want something similar to a scirpt type command like "daemon stop", "daemon start" or "daemon restart".
instead of while(true), consider having a boolean variable call it isRun or whatever. e.g. while(isRun) The loop will execute as long as isRun is true, but as soon as some other part of the program sets it to false, the loop stops. That's one way. I'm not sure if it applies to your situation or not.
the stop() command for threads that I know about is deprecated.