title: Java Multi Threading Control
body: <p>I am using this code to create threads.</p>
  
  <pre><code>      while ((strLine = br.readLine()) != null) {
                  r = new runnable(strLine);
                  new Thread(r).start();
                  x++;
                  Thread.sleep(100);
        }
  </code></pre>
  
  <p>How can I control the maximum number of threads running at any point of time?
  This code has issues where memory used keeps rising(memory leak) is there a better way to do this?
  I tried using scheduler but didnt help.</p>