I have a swingworker in my java project.
I use netbean “profiler” to monitor the thread.
I don’t know why the swingworker thread still exist in the monitor of the profiler in NetBeans and it is in “Wait” State. In other words, if i click button b 10 times, there are 10 swingworker threads!
Thank You.
public static void main(String[] args) {
// TODO code application logic here
final JFrame f = new JFrame();
f.setLayout(new BorderLayout());
f.setSize(400, 400);
b = new JButton("B1");
f.add(b,BorderLayout.CENTER);
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
return null;
}
}.execute();
}
});
f.setVisible(true);
}
To elaborate on my comment, check out the output from this modification of your code: