title: keyListener and thread not working
body: <p>Hey I'm trying to have the console print out "holding" when a key is being held. I'm using an applet
  because this code is to test key holding in applets. if any someone with good java knowledge can explain to me whats going on it will be much appreciated.</p>
  
  <p>I'm pretty sure that the problem might have something to do with the thread.</p>
  
  <pre><code>public class appletkeytest extends Applet implements KeyListener, Runnable {
  
      boolean held;
  
      public void init(){
          addKeyListener(this);
          Thread t = new Thread( this );
          t.start();
      }
  
      public void keyTyped(KeyEvent e) {
      }
  
      public void keyPressed(KeyEvent e) {
          held = true;
          System.out.println(held);
      }
  
      public void keyReleased(KeyEvent e) {   
          held = false;
          System.out.println(held);
      }
  
      public void run() {
          System.out.println(held);
  
          while(held){
              System.out.println("holding");
          }   
      }
  }
  </code></pre>