Best approach to updating JTable rapidly
Posted on 2011-10-11
I've been having a problem with my program getting bogged down when many updates happen at once.
I have a table model that has a method in it
I've tried calling this many different ways.
I have a thread receiving new data objects which stores them in a buffer, then I process the buffer in another thread, which basically gets an object from the buffer and calls updateTable in the table model with the object from the buffer.
The updateTable method takes the data and calls setValueAt(.......)
I've tried using a swingWorker for each call to the updateTable method in the processing thread.
Everything seems to work, until I get a hundred updates at once, then things come to a crawl.
It would make sense if I thought I was creating a hundred worker threads when I get the hundred updates, but I've read the swing worker uses a pool of 10 threads as a default.
I tried creating my own thread pool of 5 threads, which worked however it ran even slower.
Maybe I'm not supposed to be calling setValueAt in the model?
This is all part of a bigger program so I don't have stand alone code that runs which I can post, but I can make one tomorrow if the information I've given is not enough information.