I'm working on a Java fractal program. In my design, I would like to implement a particular ImageProducer class which computes pixels in a background worker thread when the startProduction(ImageConsumer)
gets invoked. Once set up the producer, image will be created with Component.createImage(ImageProducer)
and then shown with a call to Graphics.drawImage(Image, int, int, ImageObserver)
in the paintComponent(Graphics)
method of an appropriate subclass of JPanel, passing this
(the JPanel) as the last parameter.
Here the question: is it safe to call setter methods on registered ImageConsumers from the worker thread? Shouldn't these calls come from the EDT for the JPanel to be painted properly?