@Override
 public void run() {
   System.out.println("Thread started for ==> " + runEach);
   List<File> files = getSortedFilesInAFolder_Integer_Sort(OBJECTS);
   for (File f : files) {
     if ((Integer.parseInt(f.getName()) % TOTAL_THREAD_COUNT) == runEach) {
       // System.out.println("Thread - " + runEach + " : Reading File ==> " + f.getName());
       try {
         synchronized (QUEUE) {
           if (QUEUE.size() > (100 + (runEach * 10))) {
             QUEUE.wait();
           }
         }
         readEachFile(f);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
   }
   THREAD_EXIT_COUNTER--;
   System.out.println("Read all files for ==> " + runEach);
 }
    @Override
    public void run() {
      System.out.println("Thread-Writer: STARTED. Hello!!!");

      while (!isProcessingComplete) {
        if (QUEUE.isEmpty()) {
          if (THREAD_EXIT_COUNTER < 1) {
            isProcessingComplete = true;
            break;
          } else {
            try {
              Thread.sleep(100);
            } catch (InterruptedException ex) {
              ex.printStackTrace();
            }
          }
        } else {
          ArrayList<ArrayList<LogData>> ldss = new ArrayList<>();
          while (!QUEUE.isEmpty()) {
            ldss.add(QUEUE.poll());
            // System.out.println("Thread - Writer : Polling " + counter++);
          }
          try {
            for (ArrayList<LogData> lds : ldss) {
              processAndWriteEachBatch(lds);
            }
            synchronized (QUEUE) {
              if (QUEUE.size() < 25) {
                QUEUE.notifyAll();
              }
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      }
      System.out.println("Thread-Writer: completed processing all files. Bye!!!");
    }
 private void readEachFile(File _f) throws Exception {
   // System.out.println("Thread - " + runEach + " : Reading file > " + _f.getName());
   ArrayList<LogData> lds = serializer.read(_f);
   QUEUE.add(lds);
 }