title: JavaFX Creates Daemon Threads called "Timer-XX"
body: <p>I just recognized that my program creates a <code>Daemon Thread</code> every time I play a MP3. And they're are Named "<code>Timer-XX</code>" as everybody suggest yes XX is a increasing integer starting with zero.</p>
  
  <p>Ok I can understand that <code>JFX</code> needs them to play a MP3 but actually the MP3 is just 3 sec long and some of them stay <code>Running</code> for a couple of minutes or longer, while others normaly run out (i just suggest it should be like this).</p>
  
  <p>I would like to know why they get created in the first place? Why they stay <code>Running</code> and how I can get ride of them because as far as I know <code>Daemon</code> dose not mean stopped so it still eats Memory and CPU what I can't give away like candy in the current state of my project.</p>
  
  <p>Here is the code that plays the MP3s:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class EffectPlayer {
      private final String MP3_SUFFIX = ".mp3";
      private final static int MAX_VOLUME = 100;
      private MediaPlayer mediaPlayer;
      private int masterVolume = 50;
      private int effectVolume = 50;
  
      public EffectPlayer(File f){
          if(isMP3(f)){
              Media mp3 = new Media(f.toURI().toString());
              mediaPlayer = new MediaPlayer(mp3);
              effectVolume = Integer.parseInt(GetConfig.getVar("USER_OPTION_VOLUME_EFFECT"));
              masterVolume = Integer.parseInt(GetConfig.getVar("USER_OPTION_VOLUME_MASTER"));
              if(effectVolume &gt; masterVolume) effectVolume = masterVolume;
              mediaPlayer.setVolume(1 - (float)(Math.log(MAX_VOLUME - effectVolume) / Math.log(MAX_VOLUME)));
              mediaPlayer.setCycleCount(1);
              mediaPlayer.play();
          }
      }
  
      private boolean isMP3(File f) {
          return f.getName().toLowerCase().endsWith(MP3_SUFFIX);
      }
  }
  </code></pre>
  
  <p>The JFX Panel gets created in the class that Creates a EffectPlayer Object</p>
  
  <pre><code>@SuppressWarnings("unused")
  public static JFXPanel fxPanel = new JFXPanel();
  </code></pre>