The block finallywill still be executed. However, if the JVM has lost memory, there is a possibility that there will be a problem with closing the stream, resulting in another memory error due to the block finally. If this happens, the thread will most likely not be closed until the JVM exits.
source
share