Thread with threads

Suppose that the stream in my program was reading a file from disk, and it encountered an error (outOfMemory), and the stream was killed without the ability to close the streams indicated at the end. Will this thread maintain even after this thread kills?

+4
source share
2 answers

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.

+2
source

. .

OOM Heap , JVM. , . , OOM , : BIG, , - , GC , , ..

. , , , , . , ( , GC ).

" ". / . " " . , JVM ?

( " " ) " " try-with-resources.

, try-with-resources ( " " ) ) , " " Java ( ).

" " "/ ", .

"", , , monitor ( ).

+2
source

Source: https://habr.com/ru/post/1609498/


All Articles