title: Why does the second ball not spawn? (Java Multithreading)
body: <p>I'm practicing threads in Java and am attempting to make an animation where a series of balls fall down to the bottom of the screen. The idea is that, once a ball falls, another spawns next to it and falls as well. I made it so an "if" determines that a ball touched the bottom of the screen and allows another ball to spawn but it's not working for some reason as the second ball does not spawn. Here's the full class:</p>
  
  <pre><code>import java.awt.*;
  import java.util.*;
  import javax.swing.*;
  
  public class BallThread extends Thread {
  
      int x;
      int y;
      int directionY = 1;
      int directionX = 1;
      JWindow ballWindow = new JWindow();
      int height = Toolkit.getDefaultToolkit().getScreenSize().height;
      int width = Toolkit.getDefaultToolkit().getScreenSize().width;
      int speed = 1;
  
      @Override
      public void run() {
  
          this.height -= ballWindow.getSize().height;
          this.width -= ballWindow.getSize().width;
  
          while( true) {
              try {
                  Thread.sleep( 5 ); 
  
                  this.y += speed * this.directionY;
  
                  if( this.y &gt; this.height ) {
                      Toolkit.getDefaultToolkit().beep();
                      this.speed = 0;
                  } 
  
                  ballWindow.setLocation(this.x, this.y);
  
              } catch (InterruptedException e) { 
                  e.printStackTrace(); 
              } // catch
  
          } // while ( true )
  
      } // run
  
  
  
      public BallThread(int i, int j, int speed, String string) {
  
          boolean isDoubleBuffered = true;
  
          this.speed = speed;
  
          this.ballWindow.add( new JPanel(isDoubleBuffered ).add( new JLabel(new ImageIcon( string ) ) ) );
  
          this.ballWindow.setBackground( new Color(0,0,0,0));
  
          this.ballWindow.pack();
  
          this.ballWindow.setLocation( this.x = i, this.y = j );
  
          this.ballWindow.setVisible(true);
  
      } //constructor
  
      public static void main( String[] s ) {
  
          BallThread ball1 = new BallThread(1, 0, 1, "/Java stuff/src/ball.png");
          ball1.start();
          while(true) {
              if(ball1.speed &lt;= 0) {
                  BallThread ball2 = new BallThread(200, 0, 1, "/Java stuff/src/ball.png");
                  ball2.start();
              } 
          }
      } // main
  } // class
  </code></pre>