SwingWorker Framework for Java UI Responsiveness

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional Java Swing applications face issues with freezing or blocking when executing lengthy tasks on the Event Dispatch Thread (EDT), as they are not designed for multi-threading, leading to unresponsive user interfaces and inefficient handling of intermediate results and state information.

Innovation Solution

The implementation of improved methods and apparatus that allow lengthy tasks to be executed outside the EDT, enabling the delivery of partial results and state information to the EDT, along with coalescing method calls to improve application performance and UI responsiveness, using an enhanced SwingWorker framework that facilitates efficient interaction with Java Swing/JFC components.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If lengthy tasks are executed on the Event Dispatch Thread (EDT), then Swing components can be accessed and updated, but the UI becomes frozen or blocked and unresponsive

Engineering Contradiction:
ImproveUI responsivenessVSAvoidtask execution speed
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent divides the task execution into two separate threads: a background thread for executing lengthy computational tasks and an EDT for handling UI events. This segmentation allows the UI to remain responsive while tasks progress in the background, resolving the contradiction between UI responsiveness and task execution speed.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces an intermediary mechanism ( SwingWorker framework ) that bridges the background thread and EDT. This intermediary handles the transfer of results from the background thread to the EDT, enabling indirect interaction between non-EDT code and Swing components while maintaining thread safety and UI responsiveness.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Ease of operation

If conventional Swing utilities create runnable classes for every call, then tasks can be executed asynchronously, but computational resources are wasted and freezing problems persist

Engineering Contradiction:
Improveasynchronous task executionVSAvoidrunnable class creation overhead
Core Design Contradiction:
Ease of operationVSDevice complexity

Solution Approach 1:

The patent implements a universal reusable framework ( SwingWorker ) that can handle multiple different tasks through a single class structure. Instead of creating new runnable classes for each task, the framework reuses the same template with different implementations, reducing computational overhead while maintaining asynchronous execution capability.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The patent uses a template-based approach where a single SwingWorker template is instantiated multiple times with different tasks. This copying strategy avoids the need to create entirely new classes for each task, reducing the computational expense of class creation while preserving asynchronous execution functionality.

Inventive Principle:
Principle #26Copying

3Reliability

If all events are queued and processed sequentially on the EDT, then thread safety is maintained, but the UI appears frozen when too many events are queued

Engineering Contradiction:
Improvethread safetyVSAvoidevent processing delay
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent segments event processing by separating lengthy task execution from UI event handling. Background threads execute time-consuming operations independently, while the EDT continues to process UI events sequentially but without being blocked by lengthy tasks, thus maintaining both thread safety and UI responsiveness.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary action by executing lengthy tasks in background threads before they would block the EDT. This preliminary execution of computational work allows the EDT to remain free for UI event processing, reducing event processing delay while maintaining thread safety through proper thread coordination.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS7584478B1Framework for lengthy Java Swing interacting tasks
Publication Date: 2009.09.01 ORACLE AMERICAN INC
  • US7584478B1 patent drawing
  • US7584478B1 patent drawing
  • US7584478B1 patent drawing

AI summary

Methods and apparatuses are disclosed for sending data from a process to an event dispatch thread for output, where the event dispatch thread handling events may be related to a user interface. The method may include the steps of providing the process. The process and the event dispatch thread executing independent of one another and the process generating a first method call during execution of the process and a final result upon completion of execution, where the first method call includes a partial result generated by the executing process. The method may further include sending the first method call, storing the first method, including coalescing the first method call with an existing method call, retrieving the partial result from the first method call, and outputting the retrieved first method call on the event dispatch thread such that the partial result is displayed to a user.