0

I am attempting to execute SwingWorker's with an Executor. When I execute/submit these tasks with a thread pool size of 1, the tasks execute perfectly.

However when I execute the tasks with a thread pool size of bigger than 1 I get ExecutionException's encapsulating NullPointerException's and OutOfBoundsException's that I have seen. These exceptions do not occur when the tasks are run serially.

All tasks shared a common config file - I have now changed this so that they use their own config files. I was hoping that this would remove one area of tripping over thread unsafety.

Unfortunately I do not have access to the source code of the library I am calling asynchronously.

I really have two questions:

1). Do SwingWorker threads share resources? I'd assume that they do, and that my issue is due to a lack of thread safety in the library I am calling e.g. a singleton.

2). Can anyone comment further on the suitability of using SwingWorker with an ExecutorService? Do you have any horror stories? The reason I am using SwingWorker is that all this sits under a GUI and I would like to be able to display progress updates in the future. This is what has prevented me from just using guava's ListenableFuture instead, but if anyone has a good solution to progress updates I would be open to it.

Thanks

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Simon Perkins
  • 139
  • 1
  • 7

0 Answers0