LINUX: Swing creates indestructible JFrame-threads

From: tom baker (m3000_at_gmx.net)
Date: 09/27/04


Date: 27 Sep 2004 02:33:34 -0700

Hi there,

I'm programming an application for touchscreens. Each 'page' on the
screen is a JFrame. Among other criterions it's IMHO the easiest way
to go into 'idle'-state (by using a javax-Timer with 'dispose').

Each new JFrame (e.g. gui_start_swt_log_inst=new
cls_gui_start_swt_log(getCode()); ) creates a new linux
thread (or process). But after dispose() the thread/process of this
JFrame is still there.

Now I worry about that the whole system could
slow down or stop after a certain time, because the OS still has to
provide ressources for these non-active processes/threads.

What is the cause? java?

I hope this is part of my code ist not to short but meaningful enough:

public class cls_gui_start extends JFrame
{

    private cls_gui_start_swt_log gui_start_swt_log_inst;
    private GuiStartListener listener_gui_start;
    ...

    public cls_gui_start()
    {
        JTextField jtf_code;
        JButtons, etc.
    }

    class GuiStartListener implements ActionListener {

        public void actionPerformed(ActionEvent event)
        {

            // ----------------------------------------------------------------------------

            if ( (jtf_code.getText()).startsWith("P") )
            {

                gui_start_swt_log_inst=new
cls_gui_start_swt_log(getCode());
                gui_start_swt_log_inst.show();

                gui_start_swt_log_inst.addWindowListener(new
WindowAdapter() {
                    public void windowClosed(WindowEvent event)
                    {
                        System.out.println("gui_start: the end of
gui_start_swt_log_inst");
                    }
                });
            }
        }
    }
}

##########################################################
##########################################################
//
// Staff Work time logging

public class cls_gui_start_swt_log extends JFrame
{

    private GuiStartSwtLogListener listener_gui_start_swt_log;
    private javax.swing.Timer countdown;
    ...

    public cls_gui_start_swt_log(int code)
    {
        // Kills the window after 10 seconds if it is unused
        countdown = new javax.swing.Timer(10000, new ActionListener()
{
            public void actionPerformed(ActionEvent e) {
                countdown.stop();
                dispose();
            }
        });
        countdown.start();

        // Buttons etc.
    }

    class GuiStartSwtLogListener implements ActionListener {

    public void actionPerformed(ActionEvent event)
    {

        // ------------------------------------------------------------------------

        if (event.getSource() == btn_begin)
        {
            countdown.stop();
            // write into file
            dispose();
        }
    }
}

Thanks in advance !

tom