src/java.desktop/share/classes/javax/swing/SwingWorker.java

Print this page




 810         }
 811         return executorService;
 812     }
 813 
 814     private static final Object DO_SUBMIT_KEY = new StringBuilder("doSubmit");
 815     private static AccumulativeRunnable<Runnable> getDoSubmit() {
 816         synchronized (DO_SUBMIT_KEY) {
 817             final AppContext appContext = AppContext.getAppContext();
 818             Object doSubmit = appContext.get(DO_SUBMIT_KEY);
 819             if (doSubmit == null) {
 820                 doSubmit = new DoSubmitAccumulativeRunnable();
 821                 appContext.put(DO_SUBMIT_KEY, doSubmit);
 822             }
 823             @SuppressWarnings("unchecked")
 824             AccumulativeRunnable<Runnable> tmp = (AccumulativeRunnable<Runnable>) doSubmit;
 825             return tmp;
 826         }
 827     }
 828     private static class DoSubmitAccumulativeRunnable
 829           extends AccumulativeRunnable<Runnable> implements ActionListener {
 830         private final static int DELAY = 1000 / 30;
 831         @Override
 832         protected void run(List<Runnable> args) {
 833             for (Runnable runnable : args) {
 834                 runnable.run();
 835             }
 836         }
 837         @Override
 838         protected void submit() {
 839             Timer timer = new Timer(DELAY, this);
 840             timer.setRepeats(false);
 841             timer.start();
 842         }
 843         public void actionPerformed(ActionEvent event) {
 844             run();
 845         }
 846     }
 847 
 848     @SuppressWarnings("serial") // JDK-implementation class
 849     private class SwingWorkerPropertyChangeSupport
 850             extends PropertyChangeSupport {


 810         }
 811         return executorService;
 812     }
 813 
 814     private static final Object DO_SUBMIT_KEY = new StringBuilder("doSubmit");
 815     private static AccumulativeRunnable<Runnable> getDoSubmit() {
 816         synchronized (DO_SUBMIT_KEY) {
 817             final AppContext appContext = AppContext.getAppContext();
 818             Object doSubmit = appContext.get(DO_SUBMIT_KEY);
 819             if (doSubmit == null) {
 820                 doSubmit = new DoSubmitAccumulativeRunnable();
 821                 appContext.put(DO_SUBMIT_KEY, doSubmit);
 822             }
 823             @SuppressWarnings("unchecked")
 824             AccumulativeRunnable<Runnable> tmp = (AccumulativeRunnable<Runnable>) doSubmit;
 825             return tmp;
 826         }
 827     }
 828     private static class DoSubmitAccumulativeRunnable
 829           extends AccumulativeRunnable<Runnable> implements ActionListener {
 830         private static final int DELAY = 1000 / 30;
 831         @Override
 832         protected void run(List<Runnable> args) {
 833             for (Runnable runnable : args) {
 834                 runnable.run();
 835             }
 836         }
 837         @Override
 838         protected void submit() {
 839             Timer timer = new Timer(DELAY, this);
 840             timer.setRepeats(false);
 841             timer.start();
 842         }
 843         public void actionPerformed(ActionEvent event) {
 844             run();
 845         }
 846     }
 847 
 848     @SuppressWarnings("serial") // JDK-implementation class
 849     private class SwingWorkerPropertyChangeSupport
 850             extends PropertyChangeSupport {