title: Threads that read from text files concurently and place data in arrays
body: <p>The goal of this code is to run four threads, which will open four text files, read the words from them and then place them into a string array, </p>
  
  <p>Main problems i know of:</p>
  
  <p>1- I am not putting the concurrent function in the void run function, I want to be able to pass parameters into that function</p>
  
  <p>2- I am not sure if I am modifying the global arrays of strings or not either</p>
  
  <p>First is the main method:</p>
  
  <pre><code> public static void main(String[] args) throws IOException 
      {
           //declare the threads
           Thread thread1 =  new Thread(ReadFile("list1.txt", Global.array1,"thread1"));
           Thread thread2 =  new Thread(ReadFile("list2.txt", Global.array2,"thread2"));
           Thread thread3 =  new Thread(ReadFile("list3.txt", Global.array3,"thread1"));
           Thread thread4 =  new Thread(ReadFile("list4.txt", Global.array4,"thread2"));
  
           /*error message from netbeans: cannot find symbol
              symbol:   method ReadFile(java.lang.String,java.lang.String[])
  
              it says it for every delcaration of the thread*/
  
  
           thread1.start();  //putting the threads to work
           thread2.start();
           thread3.start();
           thread4.start();
  
           thread1.join();   //telling the threads to finish their work
           thread2.join();
           thread3.join();
           thread4.join();
  
  
           // merging the arrays into one
           List list = new ArrayList(Arrays.asList(Global.array1));
           list.addAll(Arrays.asList(Global.array2));
           list.addAll(Arrays.asList(Global.array3));
           list.addAll(Arrays.asList(Global.array4));
           Object[] theArray = list.toArray();
  
             -------------------------etc----------------------------
  </code></pre>
  
  <p>This is the "thread class" if my vocab is right</p>
  
  <pre><code>public class ReadFile implements Runnable
  {
      public void run(){
              //I should get stuff here, that's my problem!!!!
      }
  
  
      private String path;
      Thread runner;
  
      public ReadFile(String filePath, String[] toArray, String threadName) throws IOException
      {
          String path = filePath;
          FileReader fr = new FileReader(path);
          BufferedReader textReader = new BufferedReader(fr);
  
          int numOfLines = readLines();  
          toArray = new String[numOfLines];
  
          int i;
          for (i=0; i&lt;numOfLines; i++)
          {
              toArray[i]= textReader.readLine();    //place next line into string array
          }
  
          textReader.close();
      }
  
  
     int readLines() throws IOException
      {
          FileReader fr = new FileReader(filePath);
          BufferedReader bf = new BufferedReader(fr);
  
          String aLine;
          int noOfLines = 0;
  
          while((aLine = bf.readLine()) != null)
          {
              noOfLines++;
          }
          bf.close();
          return noOfLines;
      }
  
      }
  </code></pre>
  
  <hr>
  
  <p>Finally i did a class for the global variable, and i don't know if it's a good idea</p>
  
  <pre><code>public class Global 
  {
      public static String[] array1;
      public static String[] array2;
      public static String[] array3;
      public static String[] array4;
  }
  </code></pre>
  
  <p>please let me know what you guys think, any help or explanations or tips would be greatly appreciated</p>