Ignore:
Timestamp:
2008-09-16T11:50:59+02:00 (16 years ago)
Author:
stotz
Message:

Sigelton instance creation is now 100% thread safe

File:
1 edited

Legend:

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

    r10368 r10722  
    2424         */
    2525        public static JobDispatcher getInstance() {
    26                 if (instance == null)
     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;
    2735                        new JobDispatcher();
    28                 return instance;
     36                        return instance;
     37                }
    2938        }
    3039
Note: See TracChangeset for help on using the changeset viewer.