Take the 2-minute tour ×

This question already has an answer here:

Is there a way to pause/resume the SwingWorker in Java ?

share|improve this question

marked as duplicate by flup, Eran, james.garriss, Prashant Kumar, Zong Zheng Li Dec 4 '13 at 16:56


1 Answer 1

up vote 0 down vote accepted

You can pause the task you run in the swing worker by implementing something like this

while(true) {
       try {
           Thread.sleep(500); // half a second
       } catch(InterruptedException e)

It is not very nice though.

share|improve this answer
you copied code from here velocityreviews.com/forums/… but forgot to write loop :-) –  Jigar Joshi Oct 4 '10 at 7:34
Correct. Formatted it nicer though. –  Fedearne Oct 4 '10 at 7:41
Don't do it this way. Use wait() and notify() instead. –  Eric Lindauer Nov 20 '12 at 3:42
