Let’s say I have a custom thread object,
public abstract class CustomThread extends Thread {
// ....
@Override
pubic void run(){
// ...
try{
methodThatThrowsAnException ();
catch (Throwable e){ handleException(e);
}
// ....
public abstract void handleException(Throwable e);
Would it be bad practice to have an interface for catching & handling exceptions back in the main thread?
public static void main(String[] args){
Thread secondaryThread = new AnotherCustomThread(new IForeignCatcher(){
catchThrowable(Thread t, Throwable e){ e.printStackTrace(); }
} );
secondaryThread.start();
// ...
}
I’m still new to threads, someone let me know if I’m doing this completely wrong xD