Search code examples
javamultithreadingswingawtjmapviewer

Is JMapViewer thread-safe?


I'm writing an applicaton that uses JMapViewer. There are several threads (executed in a ThreadPoolExecutor) which acts over the displayed map (mainly creating/destroying and changing the color of some MapMarkerCircle). Does this violate the Single Thread Rule? Should I run the code which acts over the map in the done() method of a SwingWorker to make sure it will be executed in the Event Dispatch Thread?

Thanks.


Solution

  • Since the setter functions for markers and such on JMapViewer call repaint(), you will need to ensure they are only called on the event dispatch thread. repaint() is documented to not be thread-safe although it may currently work correctly.