According to the Java Language Specification, §11.1.1, "The Kinds of Exceptions" [JLS 2011],
The unchecked exceptions classes are the class
RuntimeExceptionand its subclasses, and the classErrorand its subclasses. All other exception classes are checked exception classes.
...
Bibliography
| [JLS 2011] | §11.2, "Compile-Time Checking of Exceptions" |
| [Kalinovsky 2004] | Chapter 16, "Intercepting Control Flow: Intercepting System Errors" |
...
In the event of actually running out of memory, it is likely that some program data will be in an inconsistent state. Consequently, it might be best to restart the process. If an attempt is made to carry on, reducing the number of threads, or just cycling them, may be a good idea because threads often leak memory.
The methods
Thread.setUncaughtExceptionHandler()andThreadGroup.uncaughtException()can be used to help deal with anOutOfMemoryErrorin threads.