The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Multiple java processes on Linux, why? I don't make threads myself.

Posted by Wensheng Deng on December 24, 2000 at 11:10 AM

Hi Java Guru,

For testing purpose, I wrote a small GUI program which builds a
JButton object and a JTextArea object. When you press the button,
a "Aha!" string will be appended in the textArea. Please see the
program in the end of this message.

My question is: when I ran it on Redhat6.2 with java1.3, I found
that I got 12~13 java processes by running command 'ps'. But on
Solaris, there is only one java process when running the same
program. What makes the difference?

Thanks a million for any hints. -Wensheng

The program is attached below =========
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MyFrame extends JFrame
{
JButton jButton = new JButton();
JTextArea jTextArea = new JTextArea();

public MyFrame()
{
try
{
init();
} catch(Exception e)
{
e.printStackTrace();
}
}

public static void main(String[] args)
{
MyFrame frame = new MyFrame();
frame.setSize(new Dimension(400,300));
frame.validate();
frame.setVisible(true);
}

private void init() throws Exception
{
jButton.setText("Press Me");
jButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jTextArea.append("Aha!");
}
});
this.getContentPane().add(jButton, BorderLayout.NORTH);
this.getContentPane().add(jTextArea, BorderLayout.CENTER);
}

protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
if( e.getID() == WindowEvent.WINDOW_CLOSING)
{
System.exit(0);
}
}
}




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us