Your SwingWorkers run in your SwingWorker thread. Therefore when you see
It seems to hang on sw2.get (), and in jdk7 there is only one thread named swingworker. On jdk6, I see 3-5 at the same time. - kd304
This is because the SwingWorker class is not a thread, and the task to be performed on the thread, and the default configuration for the ExecutorService for SwingWorker in Java 6 is different from what it was in Java 7. IE your SwingWorkerExecutorService (which is defined inside the class SwingWorker) has a different meaning for the maximum number of threads for task distribution.
//From Java 6 SwingWorker private static final int MAX_WORKER_THREADS = 10; public final void execute() { getWorkersExecutorService().execute(this); } private static synchronized ExecutorService getWorkersExecutorService() { ... private static synchronized ExecutorService getWorkersExecutorService() { new ThreadPoolExecutor(0, MAX_WORKER_THREADS, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory) }
You have only one thread on which SwingWorker tasks are running, and this first task is waiting for the completion of the second task, which cannot be started, since the thread on which the second task will be executed, waits for the second before it returns. The execution on a swingworker thread depends on the execution of another - the right way to a dead end. You can see how to use the ExecutorService to schedule events that will be executed in the SwingWorker thread, and not execute one scheduled event depending on another scheduled event completion.
Java 7 SwingWorker
source share