You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/11/26 17:10:13 UTC

[commons-vfs] 10/16: Make starting and stopping a DefaultFileMonitor safer to use from multiple threads.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git

commit 63c6912d9580b753ca5fb740be392874478c3235
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 26 10:44:24 2021 -0500

    Make starting and stopping a DefaultFileMonitor safer to use from
    multiple threads.
---
 .../main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java
index a1200cf..4efb139 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java
@@ -545,7 +545,7 @@ public class DefaultFileMonitor implements Runnable, FileMonitor {
     /**
      * Starts monitoring the files that have been added.
      */
-    public void start() {
+    public synchronized void start() {
         if (this.monitorThread == null) {
             this.monitorThread = new Thread(this);
             this.monitorThread.setDaemon(true);
@@ -557,7 +557,7 @@ public class DefaultFileMonitor implements Runnable, FileMonitor {
     /**
      * Stops monitoring the files that have been added.
      */
-    public void stop() {
+    public synchronized void stop() {
         this.runFlag = false;
         if (this.monitorThread != null) {
             this.monitorThread.interrupt();