title: why this code doesn't play the sound file
body: <p><em>The code</em></p>
  
  <pre><code>import javax.sound.sampled.*;
  import java.io.*;
  
  public class Tester {
  static Thread th;
  
  
  public static void main(String[] args) {
      startNewThread();   
     while( th.isAlive() == true) {
         System.out.println("sound thread is working");
     }
  }
  
  public static void startNewThread() {
     Runnable r = new Runnable() {
         public void run() {
             startPlaying();
         }
     };
     th =new Thread(r);
     th.start();
  } 
  public static void startPlaying() {
     try {            
          AudioInputStream ais = AudioSystem.getAudioInputStream(new File("d:/UnderTest/wavtester.wav"));
          Clip clip = AudioSystem.getClip();
          clip.open(ais);
          clip.loop(-1); // keep playing the sound                  
     } catch(Exception exc) {
         System.out.println(exc);
       }       
   }
  }
  </code></pre>
  
  <p>This code does give the output <strong>sound thread working</strong> , but does not play anything. In this code i have started a separate thread for playing sound and the program should not terminate till the sound thread has finished it's job .But the program terminates after printing series of <strong>sound thread working</strong>. </p>
  
  <p>What is the reason for this <em>( for the program terminating and the sound not playing)</em> ?</p>