Last active
September 22, 2017 05:57
-
-
Save aozturk/8e34ffd4096a38ea06b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class MyTask implements Runnable { | |
@Override | |
public void run() { | |
try { | |
System.out.println("My task is started running..."); | |
// ... | |
anotherMethod(); | |
// ... | |
} catch (Throwable t) { | |
System.err.println("Uncaught exception is detected! " + t | |
+ " st: " + Arrays.toString(t.getStackTrace())); | |
// ... Handle the exception | |
} | |
} | |
private void anotherMethod() { | |
throw new ArithmeticException(); | |
} | |
} | |
public class ProactiveHandler { | |
public static void main(String[] args) { | |
// Create a fixed thread pool executor | |
ExecutorService threadPool = Executors.newFixedThreadPool(10); | |
threadPool.execute(new MyTask()); | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment