Created
October 22, 2014 16:22
-
-
Save guigarage/eb0cb09a348fcd648601 to your computer and use it in GitHub Desktop.
JavaFX concurreny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ProcessChain.create(). | |
addRunnableInPlatformThread(() -> blockUI()). | |
addSupplierInExecutor(() -> loadFromServer()). | |
addConsumerInPlatformThread(d -> updateUI(d)). | |
onException(e -> handleException(e)). | |
withFinal(() -> unblockUI()). | |
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Runnable backgroundRunnable = () -> { | |
try { | |
data = loadFromServer(); | |
Platform.runLater(() -> { | |
updateUI(data); | |
}); | |
} catch(Exception e) { | |
Platform.runLater(() -> { | |
handleException(e); | |
}); | |
} finally { | |
Platform.runLater(() -> { | |
unblockUI(); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment