-1

My question is can SwingWorker's doInBackground method be executed more than once, by difference instances of the same class?

For example, there is a class called ClientGUI and there are 2 instances, ClientGUI1 and ClientGUI2, will each of these instances be able to call the doInBackground method of SwingWorker at least once?

robbmj
  • 16,085
  • 8
  • 38
  • 63

1 Answers1

0

No. But, what you can do is create a new instance of the SwingWorker, and then start those.

From the Java API specification:

It is never legal to start a thread more than once. In particular, a thread may not be restarted once it has completed execution.

Check out this SO question on threads: Is it legal to call the start method twice on the same Thread?

Community
  • 1
  • 1
CaffeineToCode
  • 830
  • 3
  • 13
  • 25