is SwingWorker's publish() method Thread-Safe?
843807Mar 3 2010 — edited Mar 3 2010Kind Friends,
I have a SwingWorker that publish() data to an internal List to forward to the EDT (Thread) (processing it by the process(List<E>) method).
Now the Thread SwingWorker creates new Threads for convenience (maybe using inner Thread classes), my question is:
Are these new Threads allowed to SAFELY call the publish() method too (to provide other data to display in swing)?
that is: is SwingWorker's "publish()" method Thread-Safe?
I noted 2 facts:
1) SwingWorker internally uses an ArrayList that would be NOT Thread-Safe! (a Vector would be instead)
2) SwingWorker's publish() SUN's method contains a synchronized (this) {} part that would seem to make this method Thread-Safe, but there's another part NOT synchronized (doProcess.add(chunks);)
so please may you give me a 100% correct and certain answer?
Thanks very very much for any help,
VG (Italy)