I have written a Thread with class Runnable as follows
class myThread implements Runnable {
public void start () {
thread = new Thread(this, threadName);
thread.setUncaughtExceptionHandler(handler)
thread.start()
}
@Override
run(){
while(toggle) {
try {
//do something
} catch {
throw new Runtime Exception()
}
}
}
Handler is defined in another class where
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable exception) {
toggle = false
try {
thread.start();
} catch (Exception e) {
// Exception in thread
}
try {
thread.join(200);
} catch (InterruptedException e) {
}
if (!thread.isAlive()){
// Tell Everyone Thread is Dead
} else {
System.out.println("Thread is still Alive ");
}
}
});
When I implemented this in Huawei Mobile, it works fine, thread.start, makes the run function reach its end and the thread is dead. but in Samsung tablet even after thread.join in Handler thread is still Alive.
Question: Why is there inconsistance between different devices perfomance, API and Android version is same
Question: What actually happens to thread after Runtime Exception is thrown?
Note: in Samsung Tablet for thread.start excpetion is IllegalThreadException