Skip to main content

Task<V>, Service<V>, Progress, Cancellation and Exception Handling

Learn Task<V>, Service<V>, Progress, Cancellation and Exception Handling (Phase 10 · Concurrency and Background Tasks (Essential), JavaFX) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Task<V> • Task<V> ( javafx.concurrent ) is a one-shot background job that implements Runnable , Future and Worker : you implement call() (runs on the worker thread), and observe properties updated safely on the FX thread : stateProperty ( READY, SCHEDULED, RUNNING, SUCCEEDED, CANCELLED, FAILED ), valueProperty , progressProperty , messageProperty , titleProperty , exceptionProperty , runningProperty . Callbacks setOnSucceeded/Failed/Cancelled/Running run on the FX thread. Inside call() use updateProgress(done, total) , updateMessage , updateValue (these are throttled and marshalled for you)...

More lessons in Phase 10 · Concurrency and Background Tasks (Essential)