From this thread, I get that even if the programmer has no remaining reference to an object (which becomes unreachable), it may not be ready for garbage collection. An unreachable but running Thread that hasn't been joined yet is such an example. My question is: is an unreachable JFrame that hasn't been closed yet (thus, still having a working and visible GUI interface) ready for garbage collection? If the answer is positive, will this behavior disrupt or force the closing of the GUI interface? For example, the following code snippet is taken from the book Java: A Beginner's Guide:
class SwingDemo {
SwingDemo() {
JFrame jfrm = new JFrame("A Simple Swing Application");
jfrm.setSize(275, 100);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel jlab = new JLabel(" Swing defines the modern Java GUI.");
jfrm.add(jlab);
jfrm.setVisible(true);
}
...
}
Note that the JFrame object created is no longer reachable when the SwingDemo constructor returns.