title: can multithread works faster?
body: <p>i have 2 machine (Intel Atom(TM) CPU D525) and each of them running different OS (1 windows 7 and 1 ubuntu 10.04). </p>
  
  <p>I wish to send a stack of image from Windows 7 machine to Ubuntu machine. </p>
  
  <p>I am now using multithread to do it. i have attached my code below:</p>
  
  <pre><code>public class RshScp implements Runnable
  {
  
  private StreamHandlers streamHandlers = new StreamHandlers(); 
  private String screenFileName;
  private int clientIndex;
  private SingletonServer ss = null;
  
  public RshScp(String screenFileName, int clientIndex, SingletonServer ss)
  {
      this.screenFileName = screenFileName;
      this.clientIndex = clientIndex;
      this.ss = ss;
  } 
  
  public void run()
  {
      sendFileToClient();
  }
  
  public void sendFileToClient()
  {
      try 
      {   
          DisplayClient dc = null;
          dc = ss.getClient(clientIndex);          
  
          String execution = sshFileRSH(dc.getHostName(), dc.getUserName(), screenFileName, dc.getRemoteDirectory(), dc.getLocalDirectory()); 
          log.write(execution);
          Process p1 = Runtime.getRuntime().exec(execution);              
          InputStreamReader isr = new InputStreamReader(p1.getInputStream());
          streamHandlers.checkStreamOutput("From RshScp", isr);
      } catch(Exception e){}
  }
  
  //Function to set the RSH SCP command
  private String sshFileRSH(String hostName, String userName, String localFileNames, String remoteDirName, String localJobDirectory)
  {
      String fileTransferCommand = "scp " + localFileNames;
      //String fileTransferCommand = "rsync --partial --progress --rsh=ssh " + localFileNames[0] + " " + localFileNames[1] + " " + localFileNames[2];
  
      String destinationCommand = userName + "@" + hostName + ":" + remoteDirName;
  
      String executionCommand = "";
       executionCommand = fileTransferCommand + " " + destinationCommand;
  
      return executionCommand;            
  } // end function
  
  }//end while class
  </code></pre>
  
  <p>When I try to send the file to multiple clients, I found that it is slow. It uses 5 seconds to connect and send file to client. And sometimes it still will have image lost. </p>
  
  <p>Is anyone know what actually happen that make the multithread slow? and is there any solution that can make it connect and send faster?</p>