title: JavaFX Running a large amount of countdown timers at once?
body: <p>So I can see a couple different ways to do what I need and I've done a bunch of google/stack overflow searching but can't find really what I'm looking for. I need to run multiple "Countdown timers." I need to have about 6 possibly up to 10 countdown timers running at once all at different times. I have a tab pane on my main program that I am including the FXML and injecting the controllers into. The Timers Tab has a different controller than the main program. </p>
  
  <p>So the 1st question I have is. Since this "tab" is running on a separate controller but is included into the main program, does it run on a separate application thread?</p>
  
  <p>Here is an example of what the included tab FXML looks like... </p>
  
  <p><a href="https://i.stack.imgur.com/FlGlg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FlGlg.jpg" alt="Countdown timers"></a></p>
  
  <p>When I press each start button. I can create a <code>Timeline</code> and <code>KeyFrame</code> for each timer. However, I don't really think that is the best way to go about it. Specially once you get up to 10 timelines running at the same time, and definitely if this is not running on a separate application thread from the main program. </p>
  
  <p>I thought about sending each start request to an <code>ExecutorService</code> and <code>newCacheThreadPool</code> however I need to be able to update the labels on the GUI with the current time remaining and I understand you are not supposed to do that with background services. <code>Platform.runLater()</code> maybe? </p>
  
  <p>The other idea was using the <code>Timer</code> from the <code>java.util.Timer</code> class. However, I see this as having the same problems as the <code>ExecutorService</code> when I need to update the GUI Labels. I also understand that the <code>Timer</code> class only creates one thread and performs it's tasks sequentially. So, that wouldn't work.</p>
  
  <p>Or, should I have a whole other "CountDown" class that I can create new instances of with each one and then start new threads in. However, if I do that, how do I continually update the GUI. I still would have to poll the CountDown class using a <code>timeline</code> right? So that would defeat the purpose of this whole thing. </p>