/**
   * Main
   *
   * @param args
   */
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    System.out.println("Enter 5 URLs spearated by comma");
    String input = in.nextLine();
    String[] URLs = input.split(",");
    Stopwatch endtoend = new Stopwatch();
    if (URLs.length == 5) {
      getAllPages(URLs);
    } else System.out.println("Invalid number of URLs");

    // Sort the HashMap based on Values to get the top 10 words
    sortByValue(map);
    System.out.println(System.getProperty("file.encoding"));
    System.out.println("End to end Elapsed time:" + endtoend.elapsedTime() + " milliseconds");
  }
  /**
   * Pass the url one by one to an asynchronous call to fetch the content
   *
   * @param urls
   */
  private static void getAllPages(String[] urls) {
    for (String url : urls) {
      try {
        Stopwatch timer = new Stopwatch();
        Runnable asynctask = new AsynchronousTask(url);
        Future future = executor.submit(asynctask);
        while (!future.isDone()) {
          // System.out.println("Task is in progress...");
          Thread.sleep(10);
        }
        System.out.println(
            "Time to Process URL: " + url + " " + timer.elapsedTime() + " milliseconds");

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    executor.shutdown();
    System.out.println("All Asynchronous tasks are finished!");
  }