33 import java.util.List;
34 import java.util.concurrent.*;
35 import java.util.concurrent.locks.*;
36
37 import java.awt.event.*;
38
39 import javax.swing.SwingUtilities;
40
41 import sun.awt.AppContext;
42 import sun.swing.AccumulativeRunnable;
43
44 /**
45 * An abstract class to perform lengthy GUI-interaction tasks in a
46 * background thread. Several background threads can be used to execute such
47 * tasks. However, the exact strategy of choosing a thread for any particular
48 * {@code SwingWorker} is unspecified and should not be relied on.
49 * <p>
50 * When writing a multi-threaded application using Swing, there are
51 * two constraints to keep in mind:
52 * (refer to
53 * <a href="http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html">
54 * Concurrency in Swing
55 * </a> for more details):
56 * <ul>
57 * <li> Time-consuming tasks should not be run on the <i>Event
58 * Dispatch Thread</i>. Otherwise the application becomes unresponsive.
59 * </li>
60 * <li> Swing components should be accessed on the <i>Event
61 * Dispatch Thread</i> only.
62 * </li>
63 * </ul>
64 *
65 * <p>
66 *
67 * <p>
68 * These constraints mean that a GUI application with time intensive
69 * computing needs at least two threads: 1) a thread to perform the lengthy
70 * task and 2) the <i>Event Dispatch Thread</i> (EDT) for all GUI-related
71 * activities. This involves inter-thread communication which can be
72 * tricky to implement.
73 *
|
33 import java.util.List;
34 import java.util.concurrent.*;
35 import java.util.concurrent.locks.*;
36
37 import java.awt.event.*;
38
39 import javax.swing.SwingUtilities;
40
41 import sun.awt.AppContext;
42 import sun.swing.AccumulativeRunnable;
43
44 /**
45 * An abstract class to perform lengthy GUI-interaction tasks in a
46 * background thread. Several background threads can be used to execute such
47 * tasks. However, the exact strategy of choosing a thread for any particular
48 * {@code SwingWorker} is unspecified and should not be relied on.
49 * <p>
50 * When writing a multi-threaded application using Swing, there are
51 * two constraints to keep in mind:
52 * (refer to
53 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">
54 * Concurrency in Swing
55 * </a> for more details):
56 * <ul>
57 * <li> Time-consuming tasks should not be run on the <i>Event
58 * Dispatch Thread</i>. Otherwise the application becomes unresponsive.
59 * </li>
60 * <li> Swing components should be accessed on the <i>Event
61 * Dispatch Thread</i> only.
62 * </li>
63 * </ul>
64 *
65 * <p>
66 *
67 * <p>
68 * These constraints mean that a GUI application with time intensive
69 * computing needs at least two threads: 1) a thread to perform the lengthy
70 * task and 2) the <i>Event Dispatch Thread</i> (EDT) for all GUI-related
71 * activities. This involves inter-thread communication which can be
72 * tricky to implement.
73 *
|