Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java	(revision 1948)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java	(revision 2242)
@@ -162,67 +162,68 @@
      * </p>
      */
-    private synchronized void ensureInitialized() {
-        if (index == null) {
-            index = new TaskModelIndex();
-            
-            for (IUserSession session : this.userSessions) {
-                for (ITaskInstance taskInstance : session) {
-                    index.handleTaskInstance(taskInstance);
-                }
-            }
-            
-            // count all events covered
-            int allEventsCovered = 0;
-            Collection<ITask> tasks = getTasks();
-            for (ITask task : tasks) {
-                if (task instanceof IEventTask) {
-                    allEventsCovered += task.getInstances().size();
-                }
-            }
-            
-            int[] eventCoverageRatios = new int[tasks.size()];
-            int i = 0;
-
-            // add some further measures
-            for (ITask task : tasks) {
-                TaskInfo info = index.taskMap.get(task);
-                info.addMeasure(TaskMetric.EVENT_COVERAGE_RATIO);
-                
-                int coveredEvents = info.getMeasureValue(TaskMetric.EVENT_COVERAGE);
-                int coverageRatio = 0;
-                
-                if (allEventsCovered > 0) {
-                    coverageRatio = (coveredEvents * 1000) / allEventsCovered;
-                }
-                
-                eventCoverageRatios[i++] = coverageRatio;
-                info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, coverageRatio);
-            }
-            
-            Arrays.sort(eventCoverageRatios);
-            
-            // add some further measures
-            for (ITask task : tasks) {
-                TaskInfo info = index.taskMap.get(task);
-                info.addMeasure(TaskMetric.EVENT_COVERAGE_QUANTILE);
-                int quantile = Arrays.binarySearch
-                    (eventCoverageRatios, info.getMeasureValue(TaskMetric.EVENT_COVERAGE_RATIO));
-                
-                quantile = 1000 * quantile / eventCoverageRatios.length;
-                
-                info.setCount(TaskMetric.EVENT_COVERAGE_QUANTILE, quantile);
-            }
-            
-            //index.dumpToCSV(System.out);
-            /*try {
-                OutputStream stream = new FileOutputStream(new File("tasks.csv"));
-                index.dumpToCSV(new PrintStream(stream));
-                stream.close();
-            }
-            catch (FileNotFoundException e) {
-                e.printStackTrace();
-            }*/
-        }
-        
+    private void ensureInitialized() {
+        synchronized (this) {
+            if (index == null) {
+                index = new TaskModelIndex();
+
+                for (IUserSession session : this.userSessions) {
+                    for (ITaskInstance taskInstance : session) {
+                        index.handleTaskInstance(taskInstance);
+                    }
+                }
+
+                // count all events covered
+                int allEventsCovered = 0;
+                Collection<ITask> tasks = getTasks();
+                for (ITask task : tasks) {
+                    if (task instanceof IEventTask) {
+                        allEventsCovered += task.getInstances().size();
+                    }
+                }
+
+                int[] eventCoverageRatios = new int[tasks.size()];
+                int i = 0;
+
+                // add some further measures
+                for (ITask task : tasks) {
+                    TaskInfo info = index.taskMap.get(task);
+                    info.addMeasure(TaskMetric.EVENT_COVERAGE_RATIO);
+
+                    int coveredEvents = info.getMeasureValue(TaskMetric.EVENT_COVERAGE);
+                    int coverageRatio = 0;
+
+                    if (allEventsCovered > 0) {
+                        coverageRatio = (coveredEvents * 1000) / allEventsCovered;
+                    }
+
+                    eventCoverageRatios[i++] = coverageRatio;
+                    info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, coverageRatio);
+                }
+
+                Arrays.sort(eventCoverageRatios);
+
+                // add some further measures
+                for (ITask task : tasks) {
+                    TaskInfo info = index.taskMap.get(task);
+                    info.addMeasure(TaskMetric.EVENT_COVERAGE_QUANTILE);
+                    int quantile = Arrays.binarySearch
+                            (eventCoverageRatios, info.getMeasureValue(TaskMetric.EVENT_COVERAGE_RATIO));
+
+                    quantile = 1000 * quantile / eventCoverageRatios.length;
+
+                    info.setCount(TaskMetric.EVENT_COVERAGE_QUANTILE, quantile);
+                }
+
+                //index.dumpToCSV(System.out);
+                /*try {
+                    OutputStream stream = new FileOutputStream(new File("tasks.csv"));
+                    index.dumpToCSV(new PrintStream(stream));
+                    stream.close();
+                }
+                catch (FileNotFoundException e) {
+                    e.printStackTrace();
+                }*/
+            }
+        }
     }
 
