Platform#runLater Question

Richard Bair richard.bair at
Tue Apr 2 10:42:25 PDT 2013

> Just on the topic, I've had situations where I've wanted Tasks (and Services) to run in my own threading model (e.g. for unit testing). So I've had similar wants to Mark's original request (but not directly with Platform.runLater, though that may also be useful).

Yes, I faced the same issue when writing unit tests for the concurrent package itself, and promptly cheated. There is a package-private API for calling runLater. In my tests I hook into that so that I don't call the real run later but instead a faked out one for the sake of testing. Also for checking whether I'm on the FX thread.

There is an issue around making it possible to call more of the Task / Service from a background thread. Although notifications always happen on the FX thread, you ought to be able to setup listeners and call start / stop etc from any thread (and I should properly make the classes thread safe). I'm hoping to get that done still in Lombard.


More information about the openjfx-dev mailing list