Author: nextgens
Date: 2008-01-21 12:25:09 +0000 (Mon, 21 Jan 2008)
New Revision: 17181

Modified:
   trunk/freenet/src/freenet/node/NodeClientCore.java
Log:
Fix a bad practice: we shouldn't start any thread in any constructor

Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java  2008-01-21 12:21:05 UTC 
(rev 17180)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java  2008-01-21 12:25:09 UTC 
(rev 17181)
@@ -116,16 +116,16 @@
        static final int MAX_CACHED_ELEMENTS = 256*1024; // equally arbitrary! 
FIXME hopefully we can cache many of these though

        private UserAlert startingUpAlert;
+       private final Thread backgroundBlockEncoderThread;

        NodeClientCore(Node node, Config config, SubConfig nodeConfig, File 
nodeDir, int portNumber, int sortOrder, SimpleFieldSet oldThrottleFS, 
SimpleFieldSet oldConfig, SubConfig fproxyConfig, SimpleToadletServer toadlets) 
throws NodeInitException {
                this.node = node;
                this.nodeStats = node.nodeStats;
                this.random = node.random;
                this.backgroundBlockEncoder = new BackgroundBlockEncoder();
-               Thread t = new Thread(backgroundBlockEncoder, "Background block 
encoder");
-               t.setDaemon(true);
-               t.setPriority(Thread.MIN_PRIORITY);
-               t.start();
+               backgroundBlockEncoderThread = new 
Thread(backgroundBlockEncoder, "Background block encoder");
+               backgroundBlockEncoderThread.setDaemon(true);
+               backgroundBlockEncoderThread.setPriority(Thread.MIN_PRIORITY);
                byte[] pwdBuf = new byte[16];
                random.nextBytes(pwdBuf);
                this.formPassword = Base64.encode(pwdBuf);
@@ -415,7 +415,7 @@
        }

        public void start(Config config) throws NodeInitException {
-
+               backgroundBlockEncoderThread.start();
                persister.start();
                if(fcpServer != null)
                        fcpServer.maybeStart();


Reply via email to