[251672] Fix multi threading issues
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java
index 1c26729..13e799c 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/ValidationFramework.java
@@ -69,25 +69,17 @@
  */
 public final class ValidationFramework {
 	
-	private IDependencyIndex 			_dependencyIndex;
+	private volatile IDependencyIndex 	_dependencyIndex;
 	private IPerformanceMonitor			_performanceMonitor;
 	
 	private Set<IProject> 				_suspendedProjects;
 	private boolean 					_suspendAllValidation;
 
-	private static ValidationFramework 	_me;
-	
 	/** 
 	 * Answer the singleton, default instance of this class.
 	 */
 	public static ValidationFramework getDefault(){
-		if (_me == null)return getDefault2();
-		return _me;
-	}
-	
-	private synchronized static ValidationFramework getDefault2(){
-		if (_me == null)_me = new ValidationFramework();
-		return _me;		
+		return Singleton.vf;
 	}
 	
 	private ValidationFramework(){}
@@ -143,15 +135,15 @@
 	 * other resources.
 	 */
 	public IDependencyIndex getDependencyIndex(){
-		if (_dependencyIndex != null)return _dependencyIndex;
-		return getDependencyIndex2();
-	}
-
-	private synchronized IDependencyIndex getDependencyIndex2() {
-		if (_dependencyIndex == null)_dependencyIndex = new DependencyIndex();
+		// note how the _dependencyIndex is volatile so that this double checking approach can be used.
+		if (_dependencyIndex == null){
+			synchronized(this){
+				if (_dependencyIndex == null)_dependencyIndex = new DependencyIndex();
+			}
+		}
 		return _dependencyIndex;
 	}
-	
+
 	/**
 	 * Answer a performance monitor for the validators.
 	 */
@@ -548,5 +540,16 @@
 		}
 		
 	}
+	
+	/**
+	 * Store the singleton for the ValidationFramework. This approach is used to avoid having to synchronize the
+	 * ValidationFramework.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static ValidationFramework vf = new ValidationFramework();
+	}
 
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledResourceManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledResourceManager.java
index 1b522fa..5e4d9c3 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledResourceManager.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledResourceManager.java
@@ -31,11 +31,8 @@
  */
 public class DisabledResourceManager implements IProjectChangeListener {
 	
-	private static DisabledResourceManager _me;
-	
 	public static DisabledResourceManager getDefault(){
-		if (_me == null)_me = new DisabledResourceManager();
-		return _me;
+		return Singleton.disabledResourceManager;
 	}
 	
 	private Set<IResource> _disabled = new HashSet<IResource>(100);
@@ -153,5 +150,17 @@
 		}
 		_disabled = copy;
 	}
+	
+	/**
+	 * Store the singleton for the DisabledResourceManager. This approach is used to avoid having to synchronize the
+	 * DisabledResourceManager.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static DisabledResourceManager disabledResourceManager = new DisabledResourceManager();
+	}
+
 
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledValidatorManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledValidatorManager.java
index c0dd05f..8bd219f 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledValidatorManager.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/DisabledValidatorManager.java
@@ -30,18 +30,13 @@
  */
 public class DisabledValidatorManager implements IValChangedListener {
 	
-	private static DisabledValidatorManager _me;
 	private static int _counter;
 	private static final int CacheSize = 5;
 	
 	private Map<IResource, LRUSet> _map = Collections.synchronizedMap(new HashMap<IResource, LRUSet>(5));
 	
 	public static DisabledValidatorManager getDefault(){
-		DisabledValidatorManager me = _me;
-		if (me != null)return me;
-		me = new DisabledValidatorManager();
-		_me = me;
-		return me;
+		return Singleton.disabledValidatorManager;
 	}
 	
 	private DisabledValidatorManager(){
@@ -122,5 +117,18 @@
 	public void validatorsForProjectChanged(IProject project, boolean configSettingChanged) {
 		_map.clear();
 	}
+	
+	
+	/**
+	 * Store the singleton for the DisabledValidatorManager. This approach is used to avoid having to synchronize the
+	 * DisabledValidatorManager.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static DisabledValidatorManager disabledValidatorManager = new DisabledValidatorManager();
+	}
+
 
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/MarkerManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/MarkerManager.java
index 6b30b9c..ddd2cf5 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/MarkerManager.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/MarkerManager.java
@@ -31,13 +31,10 @@
  */
 public class MarkerManager {
 	
-	private static MarkerManager _me;
-	
 	private Set<String> _markers = new HashSet<String>(50);
 	
 	public static MarkerManager getDefault(){
-		if (_me == null)_me = new MarkerManager();
-		return _me;
+		return Singleton.markerManager;
 	}
 	
 	private MarkerManager(){
@@ -178,5 +175,17 @@
 	public Set<String> getMarkers() {
 		return _markers;
 	}
+	
+	/**
+	 * Store the singleton for the MarkerManager. This approach is used to avoid having to synchronize the
+	 * MarkerManager.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static MarkerManager markerManager = new MarkerManager();
+	}
+
 
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java
index 7da5356..b1a5e83 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValManager.java
@@ -61,8 +61,6 @@
  */
 public class ValManager implements IValChangedListener, IFacetedProjectListener, IProjectChangeListener {
 	
-	private static ValManager _me;
-		
 	/**
 	 * Projects may be allowed to override the global validation settings. If that is the case then those
 	 * project specific settings are saved here. If the key exists, but the value is null, then that
@@ -86,9 +84,8 @@
 	private static final QualifiedName StatusBuild = new QualifiedName(ValidationPlugin.PLUGIN_ID, "sb"); //$NON-NLS-1$
 	private static final QualifiedName StatusManual = new QualifiedName(ValidationPlugin.PLUGIN_ID, "sm"); //$NON-NLS-1$
 			
-	public static synchronized ValManager getDefault(){
-		if (_me == null)_me = new ValManager();
-		return _me;
+	public static ValManager getDefault(){
+		return Singleton.valManager;
 	}
 	
 	private ValManager(){
@@ -1118,7 +1115,18 @@
 		case IProjectChangeListener.ProjectAdded:
 			projectChanged(project);
 			break;
-		}
-		
+		}		
 	}
+	
+	/**
+	 * Store the singleton for the ValManager. This approach is used to avoid having to synchronize the
+	 * ValManager.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static ValManager valManager = new ValManager();
+	}
+
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValOperationManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValOperationManager.java
index 1877a33..e78b6e1 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValOperationManager.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValOperationManager.java
@@ -98,8 +98,6 @@
 	 * validation finished on null 
 	 */
 	
-	private static ValOperationManager _me;
-
 	/**
 	 * This operation is in affect for a build cycle. At the end of the build it is reinitialized.
 	 */
@@ -116,9 +114,8 @@
 	 */
 	private int _discardAutoPost;
 
-	public static synchronized ValOperationManager getDefault(){
-		if (_me == null)_me = new ValOperationManager();
-		return _me;
+	public static ValOperationManager getDefault(){
+		return Singleton.valOperationManager;
 	}
 	
 	private ValOperationManager(){}
@@ -263,5 +260,17 @@
 		if (_operation == null)return new ValOperation();
 		return _operation;
 	}
+	
+	/**
+	 * Store the singleton for the ValOperationManager. This approach is used to avoid having to synchronize the
+	 * ValOperationManager.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static ValOperationManager valOperationManager = new ValOperationManager();
+	}
+
 
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValPrefManagerGlobal.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValPrefManagerGlobal.java
index a187cfa..5a587d1 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValPrefManagerGlobal.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValPrefManagerGlobal.java
@@ -44,15 +44,13 @@
 	public final static int frameworkVersion = 3;
 	
 	private List<IValChangedListener> _listeners = new LinkedList<IValChangedListener>();
-	private static ValPrefManagerGlobal _me;
 	
 	private List<Validator> _validators;
 	
 	private ValPrefManagerGlobal(){}
 	
 	public static ValPrefManagerGlobal getDefault(){
-		if (_me == null)_me = new ValPrefManagerGlobal();
-		return _me;
+		return Singleton.valPrefManagerGlobal;
 	}
 	
 	public void addListener(IValChangedListener listener){
@@ -520,4 +518,16 @@
 			return map;
 		}
 	}
+	
+	/**
+	 * Store the singleton for the ValPrefManagerGlobal. This approach is used to avoid having to synchronize the
+	 * ValPrefManagerGlobal.getDefault() method.
+	 * 
+	 * @author karasiuk
+	 *
+	 */
+	private static class Singleton {
+		static ValPrefManagerGlobal valPrefManagerGlobal = new ValPrefManagerGlobal();
+	}
+
 }
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValidatorExtensionReader.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValidatorExtensionReader.java
index 7346d61..2f8688f 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValidatorExtensionReader.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValidatorExtensionReader.java
@@ -44,7 +44,7 @@
 	
 	private static ValidatorExtensionReader _me;
 	
-	public static ValidatorExtensionReader getDefault(){
+	public synchronized static ValidatorExtensionReader getDefault(){
 		if (_me == null)_me = new ValidatorExtensionReader();
 		return _me;
 	}