New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConcurrentModificationException #81
Comments
In which way are you updating the series data? |
First at all, my modified JFrame looks like this: XChartPanel chartPanel;
Chart chart;
public modifiedJFrame() {
chart = new ChartBuilder().chartType(ChartType.Area).yAxisTitle("Time (ms)").theme(ChartTheme.GGPlot2).build();
chart.addSeries(SERIES1_NAME, new int[] {0}, new int[] {0});
chart.addSeries(SERIES2_NAME, new int[] {0}, new int[] {0});
chart.getStyleManager().setChartTitleVisible(false);
chart.getStyleManager().setXAxisTitleVisible(false);
chart.getStyleManager().setXAxisTicksVisible(false);
chart.getStyleManager().setLegendPosition(LegendPosition.InsideN);
chart.getStyleManager().setPlotBackgroundColor(new Color(0,0,0,0));
chart.getStyleManager().setChartBackgroundColor(new Color(0,0,0,0));
chartPanel = new XChartPanel(chart);
// Adding chart to jframe and doing some other things...
} Series are updated from Timer scheduled to 1 second and the TimerTask looks like this: List<Integer> series1_Y = new ArrayList<Integer>();
List<Integer> series1_X = new ArrayList<Integer>();
List<Integer> series2_Y = new ArrayList<Integer>();
List<Integer> series2_X = new ArrayList<Integer>();
// Do some work on lists and make sure they are not empty
window.chartPanel.updateSeries(window.SERIES1_NAME, series1_X, series1_Y);
window.chartPanel.updateSeries(window.SERIES2_NAME, series2_X, series2_Y); This is the only code that updates the series in my app. |
This is proving hard for me to debug since I cannot repeat the exception. Anyway, I believe the problem is occurring when two threads (the main GUI thread and the timer thread) are reading/writing to the series data array(s) at the same time. Can you try something for me? Instead of ArrayLists, can you try three different options?
Please let me know if that helps. If so, I can perhaps come up with a solution internal to XChart. |
First at all, I've doubled check my code, looking for code in other threads that might modify the list but found none, except for XChart itself (which is on other thread). I've tried changing ArrayList to Vectors, but the exception still occurs. I've looked at ConcurrentLinkedQueue, but it would require some code to be changed, so I have skipped it for now. Right now I am testing the synchronizedList method. I will let you know if I get anything new. |
That took me longer than I expected, however even with synchronizedList method the error still persists. Anything else I can do, except for the ConcurrentLinkedQueue method? I can try running the x-chart demo for a longer time and check whether it shows this error after hibernation. |
One question. Is it only occurring after waking up from hibernation? |
Previously it took place randomly, though it was very rare and most of errors occured after waking up, but lately the errors only occur after waking up. |
Also, what OS? |
Windows 8.1. I didn't do long-run tests on other machines yet. |
Thanks for the additional info. I googled about threads and waking up computers and came up completely empty-handed. Have you found anything? |
Not really, i will do some testing on Win 7 and Ubuntu and let you know. |
OK, thanks. |
Hi, |
I thing there is a bug in xchart API we are using. Actually I rendered a graph based on values comes from server in fraction of seconds. |
Use a |
…t in the demos and the exception disappears.
My app containing xchart will get the ConcurrentModificationException (as in the stacktrace below) once every few hours or when the computer wakes up from sleep/hibernation. The graph is a live area-chart updated each second.
Stacktrace:
The text was updated successfully, but these errors were encountered: