I use invokeAndWait because I need to fire off my events in order
There is no need to use invokeAndWait(). You can just use invokeLater(). The events will still be executed in order they are received.
the various fireTableDataChanged() methods.
You should not be invoking fireTableDataChanged. The TableModel will invoke the appropriate fireXXX() method. Why repaint the whole table when you may only change a few rows. The RepaintManager will consolidate multiple paint requests into one if necessary.
Edit:
Here is some code I had lying around. All updates are done to the model on the EDT and the code does not invoke the fireXXX(...) methods:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class TableThread extends JFrame
implements ActionListener, Runnable
{
JTable table;
DefaultTableModel model;
int count;
public TableThread()
{
String[] columnNames = {"Date", "String", "Integer", "Decimal", "Boolean"};
Object[][] data =
{
{new Date(), "A", new Integer(1), new Double(5.1), new Boolean(true)},
{new Date(), "B", new Integer(2), new Double(6.2), new Boolean(false)},
{new Date(), "C", new Integer(3), new Double(7.3), new Boolean(true)},
{new Date(), "D", new Integer(4), new Double(8.4), new Boolean(false)}
};
model = new DefaultTableModel(data, columnNames);
table = new JTable( model );
table.setPreferredScrollableViewportSize(table.getPreferredSize());
table.setIgnoreRepaint(false);
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
JButton button = new JButton( "Start Thread to Update Table" );
button.addActionListener( this );
getContentPane().add(button, BorderLayout.SOUTH );
}
public void actionPerformed(ActionEvent e)
{
new Thread( this ).start();
table.requestFocus();
}
public void run()
{
Random random = new Random();
while (true)
{
final int row = random.nextInt( table.getRowCount() );
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
table.setValueAt( new Integer(count++), row, 2);
table.setRowSelectionInterval(row, row);
Object[] aRow = { new Date(), "f", row, new Double(123), new Boolean(true) };
model.addRow( aRow );
}
});
try { Thread.sleep(500); }
catch(Exception e) {}
}
}
public static void main(String[] args)
{
TableThread frame = new TableThread();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
}
}
The CPU is consistent whether the frame is visible or minimized.
If you need more help then post a proper SSCCE like the code above to demonstrate the problem.