From 411673fe347509dae65643d633589e1bb36ad80d Mon Sep 17 00:00:00 2001 From: Jacobus Martinus Kruithof Date: Thu, 9 Dec 2004 22:17:24 +0000 Subject: [PATCH] In bug 32566 someone asked about the thread safety requirements in Ant. This made me perform a quick check on the main flow of the Ant project from a threading perspective. The only cause for wich the tasks specified in the build file may be executed in another thread is the parallel task. The parallel task does not ensure all variables are stored in memory before the new threads start. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277154 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Parallel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/org/apache/tools/ant/taskdefs/Parallel.java b/src/main/org/apache/tools/ant/taskdefs/Parallel.java index 1721dfb49..7d8b310a3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Parallel.java +++ b/src/main/org/apache/tools/ant/taskdefs/Parallel.java @@ -265,6 +265,14 @@ public class Parallel extends Task daemons = new TaskRunnable[daemonTasks.tasks.size()]; } + synchronized (semaphore) { + // When we leave this block we can be sure all data is really + // stored in main memory before the new threads start, the new + // threads will for sure load the data from main memory. + // + // This probably is slightly paranoid. + } + synchronized (semaphore) { // start any daemon threads if (daemons != null) {