我想从正在运行的线程中捕获异常并在调用线程中处理它。我将如何以最好的方式?
try {
Runnable connect = new Runnable() {
public synchronized void run() {
try {
... some code requiring long time
} catch(Exception e) {
..I want to catch here and send to calling thread
}
}
}
synchronized(connect) {
new Thread(connect).start();
connect.wait();
...if exception then handle it
...keep on with code if no exception occurred
}
} catch(Exception e) {
}