title: Java thread not working second time
body: <p>I know this is a common question but I couldn't find solution for my particular case.
  I have a <code>class Player implements Runnable</code> which is used to play .wav sounds when a button is clicked. </p>
  
  <p>Here is the <code>run()</code> method.</p>
  
  <pre><code>public void run() { 
  
  
  
      auline.start();
  
      int nBytesRead = 0;
      byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
  
      try { 
          while (nBytesRead != -1) { 
              nBytesRead = audioInputStream.read(abData, 0, abData.length);
              if (nBytesRead &gt;= 0) 
                  auline.write(abData, 0, nBytesRead);
          } 
      } catch (IOException e) { 
          e.printStackTrace();
          return;
      } finally { 
          auline.drain();
          auline.close();
      } 
  
  } 
  </code></pre>
  
  <p>And this is where I create and run the thread itself.</p>
  
  <pre><code>soundButtons[j].addActionListener(new ActionListener() {
  
              @Override
              public void actionPerformed(ActionEvent e) {
                  JButton button = (JButton) e.getSource();
                  int index = Integer.parseInt(button.getName());
                  Thread t = new Thread(samples[index]);
                  t.start();
  
              }
          });
  </code></pre>
  
  <p>The problem is that java doesn't allow to start the same thread two times. But i can't figure out why it isn't working because every time I am creating a new reference object <code>new Thread(samples[index]);</code> . Are there any suggestions?</p>
  
  <p>Thanks in advance </p>