Easily switching main and background threads in JavaFX