commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r925159 - /commons/proper/daemon/trunk/src/samples/SimpleDaemon.java
Date Fri, 19 Mar 2010 10:11:51 GMT
Author: sebb
Date: Fri Mar 19 10:11:51 2010
New Revision: 925159

URL: http://svn.apache.org/viewvc?rev=925159&view=rev
Log:
The "stopping" variable needs to be volatile, as it is used for communication between running
threads.
Make immutable private variables final

Modified:
    commons/proper/daemon/trunk/src/samples/SimpleDaemon.java

Modified: commons/proper/daemon/trunk/src/samples/SimpleDaemon.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/samples/SimpleDaemon.java?rev=925159&r1=925158&r2=925159&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/samples/SimpleDaemon.java (original)
+++ commons/proper/daemon/trunk/src/samples/SimpleDaemon.java Fri Mar 19 10:11:51 2010
@@ -32,9 +32,9 @@ public class SimpleDaemon implements Dae
     private ServerSocket server=null;
     private Thread thread=null;
     private DaemonController controller=null;
-    private boolean stopping=false;
+    private volatile boolean stopping=false;
     private String directory=null;
-    private Vector handlers=null;
+    private final Vector handlers;
 
     public static native void toto();
 
@@ -146,11 +146,11 @@ public class SimpleDaemon implements Dae
 
     public static class Handler implements Runnable {
 
-        private DaemonController controller=null;
-        private SimpleDaemon parent=null;
-        private String directory=null;
-        private Socket socket=null;
-        private int number=0;
+        private final DaemonController controller;
+        private final SimpleDaemon parent;
+        private String directory=null; // Only set before thread is started
+        private final Socket socket;
+        private int number=0; // Only set before thread is started
 
         public Handler(Socket s, SimpleDaemon p, DaemonController c) {
             super();



Mime
View raw message