Java provides two main types of exceptions: runtime exception and checked exception. Checked exceptions are the IO exceptions we often encounter and SQL exceptions. For such exceptions, the Java compiler forces us to catch these exceptions. Therefore, in the face of such exceptions, whether we are willing or not, we can only write a large number of catch blocks on our own to handle possible exceptions.
But there is another exception: runtime exception, also known as a runtime exception, which we can not handle. When such an exception occurs, it is always taken over by the virtual machine. For example, we have never handled nullpointerexception, which is a runtime exception, and this exception is one of the most common exceptions.
When an exception occurs during running, the system throws the exception to the upper layer and keeps processing the code. If there is no processing block, to the top layer, thread. Run () will throw the thread if it is a multi-thread, and main () will throw the thread if it is a single thread. If the thread is thrown, the thread exits. If the exception is thrown by the main program, the entire program will exit. Exception during running is a subclass of exception. It also has common exceptions and can be processed by catch blocks. But we often don't handle it. That is to say, if you do not handle runtime exceptions, after a runtime exception occurs, either the thread is terminated or the main program is terminated.
If you do not want to terminate, you must capture all running exceptions and never let the processing thread exit. The exception data appears in the queue. The normal processing should be to discard the exception data and then record the log. Normal data cannot be processed due to abnormal data. Such processing in this scenario may be a good application, but it does not mean that you should do so in all scenarios. If you encounter some errors in other scenarios, If you exit the program well, you can ignore the running exception or exit the program by explicitly controlling the exception.
From: http://ssg108.javaeye.com/blog/856488