aspose file tools*
The moose likes JavaFX and the fly likes Threads in JavaFX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Threads in JavaFX" Watch "Threads in JavaFX" New topic
Author

Threads in JavaFX

Jc Frane
Ranch Hand

Joined: Aug 15, 2013
Posts: 42
Good day!

Can I use Thread class in javafx or should I use Task and Service class?

Thank you!
Luan Cestari
Ranch Hand

Joined: Feb 07, 2010
Posts: 163

Hi,

Which is the propose/job of this new thread that you are going to code? I would say to use Executor (from Java API) using a pool of threads which can be reused.


Please, visit me for some cool tech post at www.ourdailycodes.com
Jc Frane
Ranch Hand

Joined: Aug 15, 2013
Posts: 42
Hi,

Thank you for the reply.

I am gonna use the code for my school's project. My project includes a module where I want to register new task for each employee and tracking each one of them.
I already managed to write a code where the progressbar is in TableView. I also managed to create Task object and bind its progress to the progressbar.

But I think service will do well with the help of the Executor you are referring with. In oracle documentation it said that it can be restarted and scheduled.

The problem now is, I dont know how to implement Service and Executor.

Would you mind if you provide some sample codes? I will appreciate it so much since I am just a student and found it hard to understand the API documentation.

Thank you so much!
Luan Cestari
Ranch Hand

Joined: Feb 07, 2010
Posts: 163

There are some implementation on Java SDK, so you dont need to to create your own implementation or use any external library. One of the JavaDOC of the SDK implementation for example http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html . Another example, showing how would look like the usage of Executor here https://github.com/luan-cestari/SimpleReadFiles/blob/master/src/main/java/com/ourdailycodes/simplereadfiles/main/IOBenchmark.java#L23

Kindest regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threads in JavaFX