Skip to content

Instantly share code, notes, and snippets.

@kcwill2
Last active October 30, 2015 22:10
Show Gist options
  • Save kcwill2/55de4ba292145db82266 to your computer and use it in GitHub Desktop.
Save kcwill2/55de4ba292145db82266 to your computer and use it in GitHub Desktop.
a future pinned to the JavaFx app thread
object JavaFXExecutionContext {
implicit val javaFxExecutionContext: ExecutionContext = ExecutionContext.fromExecutor(new Executor {
def execute(command: Runnable): Unit = {
Platform.runLater(command)
}
})
}
...
val mJavaFxEc = JavaFXExecutionContext.javaFxExecutionContext
...
val future = Future { comp.init() }(mJavaFxEc)//on the JavaFx thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment