diff src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 402:73c96a1d4a3a

Fix wasteful thread start
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Thu, 15 Oct 2015 04:45:16 +0900
parents 28d67bbfa9f1
children cdab1354e227
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Tue Oct 13 18:21:46 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Thu Oct 15 04:45:16 2015 +0900
@@ -59,13 +59,13 @@
     private boolean leader;
     private boolean hasViewer = false;
     private boolean normalTermination;
+
     private boolean isTreeManager;
     public boolean showTreeNode = false;
     public boolean checkDelay = false;
     public boolean addSerialNum = false;
     public boolean fixingSize = false;
     public boolean filterSingleDisplay = false;
-
     public int frameSizeWidth;
     public int frameSizeHeight;
     public int fixingSizeWidth;
@@ -85,6 +85,10 @@
         this.isTreeManager = isTreeManager;
         this.viewer = viewer;
 //        this.socket = createSocket();
+        startTreeRootFindThread();
+    }
+
+    public void startTreeRootFindThread() {
         if(isTreeManager()) {
             getCast = new TreeRootFinderListener(viewer);
             Thread treeRootFindThread = new Thread(getCast, "tree-root-find-listener");
@@ -96,6 +100,10 @@
         return isTreeManager;
     }
 
+    public void setIsTreeManager(boolean isTreeManager) {
+        this.isTreeManager = isTreeManager;
+    }
+
     public boolean isAddSerialNum() {
         return addSerialNum;
     }
@@ -105,7 +113,7 @@
     }
 
     /**
-     * handle new client accept 
+     * handle new client accept
      *     it also handle TreeVNC Command
      * @param os
      * @param is
@@ -808,10 +816,6 @@
      */
     public void createConnectionAndStart(ViewerInterface v) {
         selectPort(ConnectionParams.DEFAULT_VNC_ROOT);
-        startTreeVncCommandListener();
-    }
-
-    public void startTreeVncCommandListener() {
         acceptThread = new TreeVncCommandChannelListener(this, getAcceptPort());
         Thread thread = new Thread(acceptThread, "TreeVNC-accept");
         thread.start();