Click to See Complete Forum and Search --> : thread.stop - compile warning
pouncer
July 20th, 2008, 06:10 AM
when i have something like thread.stop()
i get a compiler warning saying
Note: * uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
any ideas how i could remove this?
Londbrok
July 20th, 2008, 08:19 AM
Do not use it. As the message says, and as pointed out in your earlier post, stop() is deprecated. You should not use it ever. You must handle thread pause / resume /stop through "regular code" in the run method.
To get rid of the warning, remove any code that uses / overrides stop() method.
Norm
July 20th, 2008, 10:36 AM
An idea that I haven't tried, so may not work, but could be a possibility:
To stop called code that is running in a thread , make your own version of the exception class that would be called if the thread is intertupted and interrupt() the thread that you want to stop. If the interrtupt throws an exception in the thread, it would invoke your class which could see what thread it was in and then sleep(<forever>) and not return to the class you wanted to stop.
Use a java command option to prepend your class definition to the classpath.
I've used this technique to trap NullPointerExceptions and force a stacktrace at that point.
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.