I have a very large application that processes 3 record sets (call them a,b,c); each contains from 0 to 100,000 record objects (these come from raw data, not a database), and these record sets arrive at various unknown intervals via different threads.
When the first record set (a) is complete I process it to extract various fields which are put into a Map of table records; when record set b is complete I extract some fields to add to the records already in the map; and then I do the same for record set c.
Once complete I show the (read only) table on screen. The whole process then repeats (for example after anything from a few milliseconds to 30 seconds later).
If the interval between displaying the current map (via the EDT) and processing the next set of records is long enough, everything is fine.
However if the interval decreases there is some kind of synchronization issue that I need help with.
In the example you may need to decrease the sleep time and/or increase the number of records.
Note that the error various, eg null pointer, array bounds exception, etc.
If anyone can help it would be greatly appreciated.
Joined: Jan 16, 2009
Sorry to be pain guys and girls, but this has been driving me nuts for a couple of days.
Your code does not follow this rule --> "Once a Swing component has been realized, all code that might affect or depend on the state of that component should be executed in the event-dispatching thread." Read this for more info.
Joined: Jan 16, 2009
The original code I posted is a complete example (cut,past,compile) to show the problem, the real app has 5 packages with around 100 classes.
I have now changed it so all GUI work is in the EDT (I think) and it works fine.
The next part (I think I'm almost finished) is finding a good synchronization point.
In the original example the makeData() method simulates the raw data that can be received and processed, this can be executed concurrently, anything from 1 to several hundred times.
As I said I think I am almost finished, if anyone is interested I will post a complete example.