public abstract class

AccumulativeRunnable

extends Object
implements Runnable
java.lang.Object
   ↳ sun.swing.AccumulativeRunnable<T>

Class Overview

An abstract class to be used in the cases where we need Runnable to perform some actions on an appendable set of data. The set of data might be appended after the Runnable is sent for the execution. Usually such Runnables are sent to the EDT.

Usage example:

Say we want to implement JLabel.setText(String text) which sends text string to the JLabel.setTextImpl(String text) on the EDT. In the event JLabel.setText is called rapidly many times off the EDT we will get many updates on the EDT but only the last one is important. (Every next updates overrides the previous one.) We might want to implement this setText in a way that only the last update is delivered.

Here is how one can do this using AccumulativeRunnable:

 AccumulativeRunnable doSetTextImpl =
 new  AccumulativeRunnable() {

Summary

Public Constructors
AccumulativeRunnable()
Public Methods
synchronized final void add(T... args)
appends arguments and sends this {@cod Runnable} for the execution if needed.
final void run()
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

This implementation calls run(List<T> args) mehtod with the list of accumulated arguments.

Protected Methods
abstract void run(List<T> args)
Equivalent to Runnable.run method with the accumulated arguments to process.
void submit()
Sends this Runnable for the execution

This method is to be executed only from add method.

[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Runnable

Public Constructors

public AccumulativeRunnable ()

Public Methods

public final synchronized void add (T... args)

appends arguments and sends this {@cod Runnable} for the execution if needed.

This implementation uses to send this Runnable for execution.

Parameters
args the arguments to accumulate
See Also

public final void run ()

When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

The general contract of the method run is that it may take any action whatsoever.

This implementation calls run(List<T> args) mehtod with the list of accumulated arguments.

Protected Methods

protected abstract void run (List<T> args)

Equivalent to Runnable.run method with the accumulated arguments to process.

Parameters
args accumulated argumets to process.

protected void submit ()

Sends this Runnable for the execution

This method is to be executed only from add method.

This implementation uses SwingWorker.invokeLater.