title: Multiple copy of file by using threads in java
body: <p>I have a simple program. She makes multiple copy of the selected file. Explain to me, please, how can I speed up the copy process by using threads?</p>
  
  <p>//Main class (interface):</p>
  
  <pre><code>public class Main extends JFrame{
      static JButton bt1, bt2, bt3;
      static JLabel lb1, lb2, lb3;
      static JTextField tf1;
      static int copyCount;
      eHandler handler = new eHandler();
      public static void main (String args[]){
          Main m = new Main("заголовок");
          m.setVisible(true);
          m.setLocationRelativeTo(null);
          m.setSize(150, 100);
          m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          m.setResizable(false);
      }
  
      public Main(String s){
          super(s);
          setLayout (new GridLayout(3, 1, 1, 1));
          bt1 = new JButton("Open file");
          bt2 = new JButton("Copy file");
          tf1 = new JTextField(5);
          add(bt1);
          add(bt2);
          add(tf1);
          bt1.addActionListener(handler);
          bt2.addActionListener(handler);
      }
  }
  
  class eHandler implements ActionListener{
      public void actionPerformed(ActionEvent e) {
          if (e.getSource()==Main.bt1){
              OpenFile op = new OpenFile();
              op.fileOpen();
          }
  
          if (e.getSource()==Main.bt2){
              Main.copyCount = Integer.parseInt(Main.tf1.getText());
              Copy cop = new Copy();
              cop.fileCopy();
          }
      }
  }
  </code></pre>
  
  <p>//The procedure for opening a file:    </p>
  
  <pre><code>public class OpenFile {
      JFileChooser chooser1;
      static File fileDat;
      static String fileName, filePath, fileFullPathName;
  
      public void fileOpen(){
          try {
              chooser1 = new JFileChooser();
              chooser1.setCurrentDirectory(new File("."));
              chooser1.setDialogTitle("Выберите файл");
              chooser1.showOpenDialog(null);
              fileDat  = chooser1.getSelectedFile();
              fileName = fileDat.getName();
              filePath = fileDat.getParent();
              fileFullPathName = fileDat.getAbsolutePath();
          } catch (Exception e) {}
      }
  }
  </code></pre>
  
  <p>//The procedure for copying a file:    </p>
  
  <pre><code>public class Copy {
      static String copyfileFullPathName[];
      public void fileCopy(){
      copyfileFullPathName = new String [Main.copyCount];
          for(int i=0; i&lt;Main.copyCount; i++){
              copyfileFullPathName [i] = OpenFile.filePath+"\\"+i+".txt";
              try {
                  Files.copy(Paths.get(OpenFile.fileFullPathName), Paths.get(copyfileFullPathName [i]));
              } catch (IOException e) {}
          }
      }
  }
  </code></pre>