Ignore:
Timestamp:
2009-12-28T13:30:18+01:00 (15 years ago)
Author:
stotz
Message:

Simplified instance creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java

    r18772 r19231  
    1818public class JobDispatcher {
    1919
    20     private static JobDispatcher instance;
     20    private static final JobDispatcher instance = new JobDispatcher();
    2121
    2222    /**
     
    2424     */
    2525    public static JobDispatcher getInstance() {
    26         // for speed reasons we check if the instance has been created
    27         // one time before we enter the synchronized section...
    28         if (instance != null)
    29             return instance;
    30         synchronized (JobDispatcher.class) {
    31             // ... and for thread safety reasons one time inside the
    32             // synchronized section.
    33             if (instance != null)
    34                 return instance;
    35             new JobDispatcher();
    36             return instance;
    37         }
     26        return instance;
    3827    }
    3928
    4029    private JobDispatcher() {
    41         instance = this;
    4230        addWorkerThread().firstThread = true;
    4331    }
     
    9179            workerThreadCount++;
    9280        }
     81        jobThread.start();
    9382        return jobThread;
    9483    }
     
    10392            setDaemon(true);
    10493            job = null;
    105             start();
    10694        }
    10795
Note: See TracChangeset for help on using the changeset viewer.