I am a bit new to threaded programming in java and have hit a wall. I have a program which rus a POP3 server(written in JAVA). I assig each new connection a thread(there is usually oly one connection at a time).
Now the oly way i know how to kill this process is to use kill -9 (on unix..I dont know how to do this on windows).
I wanted to write a shutdown method so that a user could cleanely exit the program. However, since I have never before written a program which keeps runnig until told to stop, I dont know how to implement a shutdown method.
I basically want something like this:
If the program is running then when the user calls something like:
java -jar POP3Server.jar shutdown
the program finishes all its ongoing processes and then exits cleanely.
I hope someone can help me with this.