Is there an upper limit on the number of Swing Worker threads that can be run or is it like as far as the memory supports? Also is this configurable somewhere?
A SwingWorker
is not a thread itself but a task that will be executed in a thread. Usually, you would use an ExecutorService
to execute instances of SwingWorker
; this interface also allows to set the number of threads:
int n = 20; // Maximum number of threads
ExecutorService threadPool = Executors.newFixedThreadPool(n);
SwingWorker w; //don't forget to initialize
threadPool.submit(w);
Now, if you submit more than n SwingWorker
instances, they'll have to queue up and wait until a thread from the pool gets available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With