201 * if ("progress".equals(evt.getPropertyName())) {
202 * progressBar.setValue((Integer)evt.getNewValue());
203 * }
204 * }
205 * });
206 *
207 * task.execute();
208 * System.out.println(task.get()); //prints all prime numbers we have got
209 * </pre>
210 *
211 * <p>
212 * Because {@code SwingWorker} implements {@code Runnable}, a
213 * {@code SwingWorker} can be submitted to an
214 * {@link java.util.concurrent.Executor} for execution.
215 *
216 * @author Igor Kushnirskiy
217 *
218 * @param <T> the result type returned by this {@code SwingWorker's}
219 * {@code doInBackground} and {@code get} methods
220 * @param <V> the type used for carrying out intermediate results by this
221 * {@code SwingWorker's} {@code publish} and {@code process} methods
222 *
223 * @since 1.6
224 */
225 public abstract class SwingWorker<T, V> implements RunnableFuture<T> {
226 /**
227 * number of worker threads.
228 */
229 private static final int MAX_WORKER_THREADS = 10;
230
231 /**
232 * current progress.
233 */
234 private volatile int progress;
235
236 /**
237 * current state.
238 */
239 private volatile StateValue state;
240
241 /**
|
201 * if ("progress".equals(evt.getPropertyName())) {
202 * progressBar.setValue((Integer)evt.getNewValue());
203 * }
204 * }
205 * });
206 *
207 * task.execute();
208 * System.out.println(task.get()); //prints all prime numbers we have got
209 * </pre>
210 *
211 * <p>
212 * Because {@code SwingWorker} implements {@code Runnable}, a
213 * {@code SwingWorker} can be submitted to an
214 * {@link java.util.concurrent.Executor} for execution.
215 *
216 * @author Igor Kushnirskiy
217 *
218 * @param <T> the result type returned by this {@code SwingWorker's}
219 * {@code doInBackground} and {@code get} methods
220 * @param <V> the type used for carrying out intermediate results by this
221 * {@code SwingWorker's publish} and {@code process} methods
222 *
223 * @since 1.6
224 */
225 public abstract class SwingWorker<T, V> implements RunnableFuture<T> {
226 /**
227 * number of worker threads.
228 */
229 private static final int MAX_WORKER_THREADS = 10;
230
231 /**
232 * current progress.
233 */
234 private volatile int progress;
235
236 /**
237 * current state.
238 */
239 private volatile StateValue state;
240
241 /**
|