I am not clear about thread confinement. In swing all the gui components must be updated through the EDT. SwingWorker is provided in Java6 for lengthy operations, and in the done method the gui components can be updated. My understanding was that the gui components in the done() method are updated in the EDT. Therefore there should be no synchronization problems. But here link text
it says:
Because the ImageRetriever class will download an image and place it on a large label, providing the label and image URL in the constructor is convenient. ImageRetriever needs the URL to retrieve an image. Provide the label so that the ImageRetriever instance can set the label's icon itself. If you use inner classes, you might not even provide this information in the constructor, because the worker thread will be able to access the information directly. However, providing the information in the constructor helps your application to be more thread-safe because that information will not be shared among ImageRetriever instances
I am confused on this. If the SwingWorker methods update the gui components (in the example of the link the JLabel) in the EDT, why is it more thread-safe to not share them among ImageRetriever(=SwingWorker) instances? If we have multiple SwingWorkers and in the done() method they update the same component, we must use synchronization primitives for the update? Am I missunderstanding something? Doesn't thread-confinement mean that only 1 thread will do all the actions? Aren't swingworkers thread-confined?
Thanks