title: Getting input from console in Java: Is it blocking or non-blocking?
body: <p>I'm writing a Java program in which I read a line from Console, and do some processing around it. The processing might take 1-2 seconds (i.e. takes longer than the input rate), while I might keep receiving 50 lines per second.</p>
  
  <p>Although there were some similar questions, they were addressing C/C++ and not Java. So my fundamental question is below: </p>
  
  <p>While still processing an input/line, am I blocked from receiving new inputs? Or somehow they are queued in the system/JVM? Or better ask this way: <strong>Do I miss any lines while processing takes time?</strong> I don't want to miss any lines by any means.</p>
  
  <p>Here is my code snippet:</p>
  
  <pre><code>Scanner sc = new Scanner(System.in);
  
  while(sc.hasNext()){
      //process line. Can take 1-2 seconds.
      processInput(sc.nextLine());
  }
  sc.close();
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>As suggested, I came up with making my code more thread-friendly, using <code>Executors</code>:</p>
  
  <pre><code>ExecutorService executorService = Executors.newFixedThreadPool(10);
  while (sc.hasNext()) {
          executorService.submit(new Runnable() {
              public void run() {
                  processInput(sc.nextLine());
              }
          });
  }
  </code></pre>