SwingWorker
is your best choice, because it will manage several threads for you.
Here is more about it http://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html
UPDATE:
doInBackground
is executed on a separate (not a UI) thread and usually used for a long non-UI process. Method done
is executed on UI thread when the long process is finished. So create and show your dialog before creating SwingWorker
. Than run your background process using SwingWorker
, in done
- hide the dialog.