title: Audio not Working Correctly
body: <p>The last time I asked how to use background audio correctly, I was told I had to use a thread. Now, I have done that, yet I still have the same problem: It does not run the rest of the program until the song completes, yet I need it to play in the background! help anyone? (Sorry for no comments in the code. If you all really feel there needs to be some to help you out I will update it with comments). </p>
  
  <pre><code>import javax.swing.JOptionPane;
  import javax.swing.JDialog;
  import java.io.*;
  import javax.sound.sampled.*;
  
  public class PokemonDemo3 implements LineListener
  {
     private boolean done = false;
  
  public  void update(LineEvent event) 
  {
      if(event.getType() == LineEvent.Type.STOP || event.getType() == LineEvent.Type.CLOSE) 
      {
           done = true;
      }
  }
  
  public void waitonfinish() throws InterruptedException 
  {
    while(!done) 
    {
         Thread.sleep(1000);
    } 
  }
  
  public static void playSound(final String url) 
  {
      try 
      {
          Clip clip = AudioSystem.getClip();
          AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(url));
          PokemonDemo3 control = new PokemonDemo3();
          clip.addLineListener(control);
          clip.open(inputStream);
          clip.start();
          control.waitonfinish();
  
      }
      catch (Exception e) 
      {
          System.err.println(e.getMessage());
      }
  }
  
  
  public static void main(String [] args)
  {
      String holder;
      int response;
      String[] options = {"Boy", "Girl"};
  
      Pokemon intro = new Pokemon();
      playSound("/Users/2018658/Desktop/pokemon.wav");
   }
  </code></pre>