[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/ValOperationManager.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValOperationManager.java
index d4ead81..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.
 	 */
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;
 	}