Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Garbage collection and what happens to resources when a program ends

929204Apr 12 2012 — edited Apr 15 2012
Hello everyone,
Could someone tell me what happens to resources when a program ends?
Are resources such as a "java.sql.Connection" or a "java.nio.channels.WritableByteChannel" automatically closed when an application ends?

Also, is there some kind of garbage collection that takes place? According to Effective Java 2nd edition item 7, "It is entirely possible, even likely, that a program terminates without executing finalizers on some objects that are no longer reachable." What happens, then?

Thanks in advance!

Edited by: Jujubi on Apr 12, 2012 10:36 AM
This post has been answered by EJP on Apr 12 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2012
Added on Apr 12 2012
14 comments
400 views