Hi folks,

Please forgive a bit of a n00b question, but I'm working with the SwingWorker class and want to create a subclass of this which includes an input type, as well as the existing output and progress-message types (so basically I'd have "CTSwingWorker< I, O, M >"). Now, I'm aware that execute() gets called on a seperate thread than doInBackground(). What I want to do is provide 2 new methods to the CTSwingworker class:

public void execute( I input ) {...}
protected abstract O doInBackground( I input );

The snag is, I would need to make the input thread-safe, so my question is, how do I go about this?

Thanks, Lee.

5 Years
Discussion Span
Last Post by mKorbel

very good choise, this one is very PowerFull methods for GUI based BackGround Tasks, I never had problems with that

SwingWorked never should be ThreadSafe(some bugs, one with Executor still in Top25 for Java <1.6.22), but you can implements/wrote bad, good or excelent workAround ...

I didn't see your code, and sure doesn't matter how is SwingWorker thread-safe or not (there are lots of non-safe Java methods too), everyting is just and only about code you can write,

the we can speak about any hepl, if not never mind google still exists

I think that never will be outDated http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html

Edited by mKorbel: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.