Deprecated Thread Methods Are Not Supported
Solution 1:
In Android its better to use Handler
for managing the Thread
and Runnables
Create an Handler instance
Handlerhandler=newHandler();
Create a Runnable thread
Runnablerunnable=newRunnable() {
@Overridepublicvoidrun() {
Log.d("runnable started", "inside run");
handler.removeCallbacks(runnable);
handler.postDelayed(runnable, 1000);
}
};
And start the Runnable using Handler
handler.postDelayed(runnable, 1000);
And to stop the Runnable use
handler.removeCallbacks(runnable);
Solution 2:
This link tells you exactly what the problem is, and how to resolve it:
What is this log, when I coded thread.stop()?
Thread.stop is a deprecated API, and deprecated thread methods aren't supported in Android. Therefore it's throwing an UnsupportedOperationException.
The answer is not to use Thread.stop - shut down your threads in a more graceful way, for example by setting a flag which the thread checks periodically.
This link discusses why thread.stop() is deprecated (long ago deprecated in Java, not just Android!):
http://docs.oracle.com/javase/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html
Post a Comment for "Deprecated Thread Methods Are Not Supported"