Should I create a new instance of Java SwingWorker every time I want to call doInBackground ()?

My extended SwingWorker class does a potentially repeating background job that requires input of GUI input variables.

I see 2 encoding options:

  • To start a new instance of the class every time I use it and pass variables to the constructor. I suppose I have to make sure that there are not many cases. If so, how? multi-ton or some other method?

  • Refresh variables and make the call again? If so, how do I do it? I don’t interrupt?

Is one of these options a way or is there a better way?

+5
source share
2 answers

Use case for Plase 1.

. , , , , .

Java , , .

+3

SwingWorker , , , , .

JavaDocs

SwingWorker . SwingWorker doInBackground .

+5

All Articles