Am Donnerstag, 6. August 2015, 12:25:19 schrieb Rahman USTA: > Hello all; > > I'm developing AsciidocFX <https://github.com/asciidocfx/AsciidocFX> . > Everything is good with JavaFX but I have some trouble of it's threading > model. > > My case is; > > AsciidocFX converts AsciiDoc documents to another formats (html, docbook, > etc.) with asciidoctor.js using a WebView component . When we are using big > AsciiDoc files (for example a book), generating docbook or something takes > some seconds. While converting AsciiDoc documents, UI is being unresponsive > until conversion completed because Asciidoctor.js must be run on JavaFX > Application Thread and conversion takes long time. I think there must be a > hack or something to handle that scenario. > > I thought to use HTML 5 Web Worker in WebView, but it will brings me more > complexity in JavaScript side. I need a solution in Java FX side. > > Thanks.
Can you tell me the classes (method) which you call and the freeze occure? You should stop your ExecuterService, and avoid using System.exit Take a look at javafx.concurrent.Task; and do not calculate the result in FX Thread example: https://github.com/asciidocfx/AsciidocFX/blob/master/src/main/java/com/kodcu/boot/AppStarter.java StartupNotification.registerStartupListener(parameters -> { threadService.runActionLater(() -> { String[] files = parameters.split(" "); for (String file : files) { file = file.replace("\"", ""); tabService.addTab(Paths.get(file).toAbsolutePath()); } }); }); if replace may be expensive StartupNotification.registerStartupListener(parameters -> { String[] files = parameters.split(" "); for (String file : files) { final Path myFile = Paths.get( file.replace("\"", "")).toAbsolutePath(); threadService.runActionLater(() -> { tabService.addTab(myFile); // <<< only do this in FX thread }); } }); this would be better to avoid freeze. replace is just for illustrate the problem. -- Jens Kapitza p.s. sorry for my bad english