Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

is SwingWorker's publish() method Thread-Safe?

843807Mar 3 2010 — edited Mar 3 2010
Kind 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)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2010
Added on Mar 3 2010
3 comments
265 views