title: Thread in [WAITING] state while instantiating new char
body: <p>I've recently stumbled upon a bug that I can't quite explain:</p>
  
  <p>A thread is in a <code>[WAITING]</code> state while seems to be executing <code>char buf[] = new char[count + otherLen];</code> inside <code>java.lang.String.concat(String.java:2021)</code>.</p>
  
  <p>This is the stacktrace: </p>
  
  <pre><code>"WORKER3"/[WAITING]
      java.lang.String.concat(String.java:2021)
      java.net.URLClassLoader$1.run(URLClassLoader.java:357)
      java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      java.security.AccessController.doPrivileged(Native Method)
      java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Class.java:186)
      [...]
  </code></pre>
  
  <p>Now, from the <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.State.html" rel="nofollow noreferrer">Oracle JDK7</a> documentation we can see that a thread in <code>WAITING</code> state is:</p>
  
  <blockquote>
    <p>Thread state for a waiting thread. A thread is in the waiting state
    due to calling one of the following methods:</p>
  
  <pre><code>Object.wait with no timeout   
  Thread.join with no timeout   
  LockSupport.park
  </code></pre>
  </blockquote>
  
  <p>But the source code of <code>String.concat</code> doesn't seem to use any of this: </p>
  
  <pre><code> 2016       public String concat(String str) {
   2017           int otherLen = str.length();
   2018           if (otherLen == 0) {
   2019               return this;
   2020           }
   2021           char buf[] = new char[count + otherLen];
   2022           getChars(0, count, buf, 0);
   2023           str.getChars(0, otherLen, buf, count);
   2024           return new String(0, count + otherLen, buf);
   2025       }
  </code></pre>
  
  <p>I have a feeling that this could be correlated to garbage collection but I can't find any evidence of such correlation.</p>
  
  <p>Can anybody shed some light on it?</p>