filmov
tv
How do you handle an unhandled exception in the thread in java

Показать описание
This is the most important question asked by a interviewer in interview room. If you have knowledge about exception handling then you are going to say that we will handle with sorrounding the code by try catch block. But this answer is wrong and control is not going to catch or finaly block and program is going to terminate abnormally.
We can handle it in two ways :-
1. Inside run() method of thread sorround the code which may throw uncaught exception with try-catch block. You may also called this way of handeling as proactive approach.
2. By setting the uncaughe exception handler in thread.
To get the code of this program go through the below url
We can handle it in two ways :-
1. Inside run() method of thread sorround the code which may throw uncaught exception with try-catch block. You may also called this way of handeling as proactive approach.
2. By setting the uncaughe exception handler in thread.
To get the code of this program go through the below url