... Fibonacci-Taskuntil the current one completes, then we clear the
fibonacciLabel(so an old result is not displayed when a new
Lines 44–47 use
setOnSucceededto register a listener (implemented as a lambda) that’s invoked when the
Taskenters the succeeded state—that is, when the
Tasksuccessfully runs to completion. In this case, we call the
getValuemethod (from interface
Worker) to obtain the result, which we convert to a
String, then display in the
fibonacciLabel. Then we enable the
goButtonso the user can start a new
You also can register listeners for a
Task’s canceled, failed and scheduled states.
Finally, lines 50–53 use an
ExecutorService to launch the
FibonacciTask (line 52), which ...