title: Java - Brute Forcing Algorithm
body: <p>I've been trying to make a brute forcing algorithm, but it doesn't seem to work. It stops after three Strings generated and freezes.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public static final char[] CHARSET_1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890./,[]\;\'\"".toCharArray();
  public final ExecutorService executor = Executors.newFixedThreadPool(30);
  
  protected void recur(final String base, final int times) {
      if (base.length() &lt; times) {
          for (final char c : CHARSET_1) {
              final String b = base + c;
              System.out.println("Current: " + b);
              executor.execute(new Runnable() {
                  public void run() {
                      recur(b, times);
                  } // I also tried it without the executor, same results.
              });
          }
      }
  }
  
  public void bruteforce() {
      final Thread generator = new Thread(new Runnable() {
          public void run() {
              recur("", 5);
          }
      });
      generator.start();
  }
  </code></pre>
  
  <p>In the function
  <code>recur("", 5);</code>, 5 means the generate strings up to the length of 5 + 1.</p>
  
  <p>Here's the output I get:</p>
  
  <pre><code>a
  aa
  aaa
  </code></pre>
  
  <p>Then it freezes. I cannot figure out why. I think it might be a memory leak issue, but I don't know. I also tried it without ThreadPools, but I seem to get the same issue...</p>
  
  <p>Any help is appreciated, thanks a ton! :)</p>