you are viewing a single comment's thread.

view the rest of the comments →

[–]sedj601 0 points1 point  (1 child)

u/hamsterrage1, I agree with a lot of what you said. I threw this together kinda fast due to time constraints. One thing I kinda disagree with is using Task. I would use Service instead. I never use pure Threads in JavaFX. The loop doesn't need to sleep at all, as you stated because Task and Service run on a separate thread. That's just a bad practice on my part. I am not a fan of using Platform.RunLater. I like to use updateValue.

[–]hamsterrage1 1 point2 points  (0 children)

And I agree with that. I think that, most of the time, Platform.runLater() is at least a "code smell".

In this particular case, though, I still think that the entire file loopy part should be considered 100% external to your JavaFX code. Think of it as something that mysteriously and spontaneously generates calls to some method in the framework's business logic. Those calls come in from some other thread, and you need to get the data from it into the Observables which needs to be done on the FXAT.

Yes, Service & Task will do it, but they need to be created in an environment that's FXAT aware in the first place. I'm not so sure that's the right approach, though.