Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use javafx.concurrent Task and Service correctly for background work and responsive UIs.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-13 | ✗→✓ | ▲ Improved | -27% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 23% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 4% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 38% | 0% |
| case-04 | ✓→✓ | = Same ✓ | -15% | 0% |
Use this skill when expensive work must stay off the JavaFX Application Thread while the UI remains observable and responsive.
javaimport javafx.concurrent.Task; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import javafx.scene.layout.VBox; public class LoaderView extends VBox { public LoaderView() { var status = new Label("Idle"); var progress = new ProgressBar(0); var button = new Button("Load"); button.setOnAction(event -> { Task<String> task = new Task<>() { @Override protected String call() throws Exception { updateMessage("Loading data..."); updateProgress(0.5, 1.0); Thread.sleep(250); updateProgress(1.0, 1.0); return "Done"; } }; status.textProperty().bind(task.messageProperty()); progress.progressProperty().bind(task.progressProperty()); task.setOnSucceeded(done -> { status.textProperty().unbind(); status.setText(task.getValue()); }); var thread = new Thread(task, "loader-task"); thread.setDaemon(true); thread.start(); }); getChildren().addAll(status, progress, button); } }
Task for one-shot work and Service for restartable workflows.javafx-architecture-frameworks for overall application service design andjavafx-reactive-binding-state for stream-based state pipelines.
call().setOnFailed(...) or worker state bindings instead of swallowingexceptions.
Other measured skills in the registry, with their headline benchmark lift.