+ /**
+ * single thread that handles display of dialogs to user.
+ */
+ ExecutorService dialogExecutor=Executors.newSingleThreadExecutor();
+ /**
+ * flag indicating if dialogExecutor should try to acquire a permit
+ */
+ private volatile boolean dialogPause=true;
+ /**
+ * pause the queue
+ */
+ private java.util.concurrent.Semaphore block=new Semaphore(0);
+
+ /**
+ * add another dialog thread to the queue
+ * @param prompter
+ */
+ public void addDialogThread(final Runnable prompter)
+ {
+ dialogExecutor.submit(new Runnable()
+ {
+ public void run()
+ {
+ if (dialogPause) {
+ try { block.acquire(); } catch (InterruptedException x){};
+ }
+ if (instance==null)
+ {
+ return;
+ }
+ try
+ {
+ SwingUtilities.invokeAndWait(prompter);
+ } catch (Exception q)
+ {
+ Cache.log.warn("Unexpected Exception in dialog thread.", q);
+ }
+ }
+ });
+ }