O'Reilly logo

Pro JavaFX 8 by James Weaver, Dean Iverson, Stephen Chin, Weiqi Gao, Johan Vos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9781430265740_Fig07-09.jpg

Figure 7-9. The WorkerAndTaskExample program after the task succeeded

If, instead of letting the task finish normally, we click the Cancel button, the task will finish immediately and the screenshot in Figure 7-10 results. Notice that the State field has the value CANCELLED now. The Value field contains the string we passed to the updateValue() method when the task was cancelled. When we detect that the task is cancelled, we have two choices of exiting from the method body. In the program in Listing 7-7, we chose to update the Value and return from the method. We could also have chosen to exit from the method body by throwing a RuntimeException ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required