I have a multithreaded application where each thread opens a stream on a URL and reads lines from it. However, the entire program may be terminated at any time with System.exit(). If I open the stream with try-with-resources, will the stream be closed on exit?
Asked
Active
Viewed 35 times
0
-
The stream won't be closed in Java, but I'd expect the OS resources to be cleaned up, if that's what you mean. – Louis Wasserman Nov 20 '15 at 19:19
-
Also see https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html: "If the JVM exits while the try or catch code is being executed, then the finally block may not execute." – M A Nov 20 '15 at 19:23