Skip to content

Commit 4bc539c

Browse files
author
Stephen Colebourne
committed
Document synchronization
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@490987 13f79535-47bb-0310-9956-ffa450edef68
1 parent 53ff5a5 commit 4bc539c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/java/org/apache/commons/io/FileCleaner.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class FileCleaner {
4949
/**
5050
* Collection of <code>Tracker</code> instances in existence.
5151
*/
52-
static Collection /* Tracker */ trackers = new Vector();
52+
static Collection /* Tracker */ trackers = new Vector(); // synchronized
5353
/**
5454
* Whether to terminate the thread when the tracking is complete.
5555
*/
@@ -128,6 +128,7 @@ public static void track(String path, Object marker, FileDeleteStrategy deleteSt
128128
* @param deleteStrategy the strategy to delete the file, null means normal
129129
*/
130130
private static synchronized void addTracker(String path, Object marker, FileDeleteStrategy deleteStrategy) {
131+
// synchronized block protects reaper
131132
if (exitWhenFinished) {
132133
throw new IllegalStateException("No new trackers can be added once exitWhenFinished() is called");
133134
}
@@ -171,6 +172,7 @@ public static int getTrackCount() {
171172
* One called, no new objects can be tracked by the file cleaner.
172173
*/
173174
public static synchronized void exitWhenFinished() {
175+
// synchronized block protects reaper
174176
exitWhenFinished = true;
175177
if (reaper != null) {
176178
synchronized (reaper) {
@@ -179,7 +181,7 @@ public static synchronized void exitWhenFinished() {
179181
}
180182
}
181183

182-
// -----------------------------------------------------------------------
184+
//-----------------------------------------------------------------------
183185
/**
184186
* The reaper thread.
185187
*/

0 commit comments

Comments
 (0)