-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0_02
-
x86
-
windows_nt
Name: boT120536 Date: 03/07/2001
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)
The error can be reproduced only under Java 1.3.0 (also with 1.3.0_02) under Windows (NT, 95 and 98).
It couldn't be reproduced with Java 1.3.0 under Linux.
It couldn't be reproduced with Java 1.2.2 under Windows.
Java 1.3 doesn't seem to be 100% 1.2.2 compliant.
If I have a cycle that creates Threads, which run() methods create and make
Swing classes visible, not all Thread will be fully executed.
I've made a 'telnet' program, that can have more window in a tabbed pane.
A simpified version is enclosed. You can start by pressing 'Test' button 30
Threads. These Threads create an own 'TelnetPanel' and insert it into a
JTabbedPane. But sometimes not all panel will be created under Windows with
Java 1.3.0 in the for() cycle. I've created tracepoints, and it seems so, that
there is deadlock in the constructor of a swing class. If you have a slower or
older PC, the error can be reproduced more often. In average 2 cases of 10
tests show the error. You can reproduce easier the problem if you always make
a new DOS window.
My original program has a really deadlock and can be stopped only with ctrl c,
if the for cycle is in a modal JDialog. If they are not in a modal dialog, not
all of them appears. But if I click on close icon of the window, some of them
appear, but not every one.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//import telnet.*;
import java.util.*;
public class Test
{
public static JTabbedPane pane = new JTabbedPane();
static class MyThread extends Thread
{
String name = "";
TelnetPanel telnetPanel = null;
public MyThread(String name)
{this.name = name;
}
public void run()
{
telnetPanel = new TelnetPanel();
telnetPanel.setParent(pane);
pane.addTab(name, telnetPanel);
}
}
public static void main(String[] args)
{JFrame frame = new JFrame();
JPanel panel = new JPanel(new BorderLayout());
frame.setContentPane(panel);
panel.add(pane, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{//it was implemented a Confirmation dialog here
//JDialog d = new JDialog(new JFrame(), "Confirmation", true);
//d.setSize(300, 200);
//d.setVisible(true);
}
});
JButton newButton = new JButton("test");
newButton.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{for(int a = 0; a < 30; a++)
{new MyThread(Integer.toString(a)).start();
}
}
});
panel.add(newButton, BorderLayout.SOUTH);
frame.setSize(600, 500);
frame.setVisible(true);
}
}//End of class Test
class TelnetPanel extends JPanel
{JTextField inputField = null;
JTextArea output = null;
JScrollPane scrollPane = null;
// Telnet telnet = null;
JTabbedPane parent = null;
int telnetLines = 100;
public TelnetPanel()
{super(new BorderLayout());
inputField = new JTextField();
inputField.setBackground(Color.black);
inputField.setForeground(Color.white);
inputField.setCaretColor(Color.white);
inputField.setFont(new Font("DialogInput", Font.PLAIN, 12));
inputField.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{sendInput();
}
});
add(inputField, BorderLayout.SOUTH);
JPanel buttonPanel = new JPanel(new FlowLayout());
add(buttonPanel, BorderLayout.NORTH);
JButton clearButton = new JButton("Clear");
clearButton.setMnemonic(KeyEvent.VK_A);
clearButton.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{clear();
}
});
buttonPanel.add(clearButton);
JButton closeButton = new JButton("Close");
closeButton.setMnemonic(KeyEvent.VK_S);
closeButton.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{close();
}
});
buttonPanel.add(closeButton);
output = new JTextArea();
output.setEditable(false);
output.setForeground(Color.white);
output.setBackground(Color.black);
output.setFont(new Font("DialogInput", Font.PLAIN, 12));
scrollPane = new JScrollPane(output);
add(scrollPane, BorderLayout.CENTER);
}
public void sendInput()
{int counter = 0;
output.append(inputField.getText() +"\n");
//if (telnet != null) telnet.write(inputField.getText());
inputField.setText("");
}
/*
public void setTelnet(Telnet telnet)
{this.telnet = telnet;
}
public Telnet getTelnet()
{return telnet;
}
*/
public void setParent(JTabbedPane parent)
{this.parent = parent;
}
public void clear()
{output.setText("");
inputField.requestFocus();
}
public void close()
{
//if (telnet != null) telnet.exit();
if (parent != null) parent.remove(this);
}
//received(): callback for class Telnet
public void received(String text, String cluster)
{//System.out.println("RECEIVED<" + text + ">");
output.append(text);
}
}
(Review ID: 118205)
======================================================================
- duplicates
-
JDK-4327067 Potential hang in multithreaded calls to UIDefaults.get()
-
- Resolved
-