Posted By:
Edward_Harned
Posted On:
Tuesday, March 27, 2001 11:39 AM
First, there is no automatic "Java" way to stop a thread. You must build a method into the class to recognize a stop situation. There once was a stop() method but it never worked well and has since been deprecated. There are operating system commands to stop a thread such as: kill -9 . You can always write you own, but the problem is getting the waiting Java thread to activate. JavaWorld.com had a series on threads with ways to stop an executing thread and there are many books on the subject.
Next, the Singleton code you mention does not work. Again, JavaWorld.com had an excellent article on why this is so. It is too involved to duplicate here.
Simply go to http://www.javaworld.com and search the articles for singleton and for threads.