I made a Java utility that does a search inside XML inside the x number of fancy zip files (twx).
This was originally a command line utility and did not perform threading.
When I moved it to use JavaFX, I ran into problems with freezing, and then translated all the searches into the task object that needs to be fixed.
I needed a way to track progress, so I implemented the Progress and ProgressBar property for tracking.
This worked fine, but since I'm already multi-threaded, why not create a thread for each Zip search. Unfortunately, this did not work.
To track, I create an array of tasks, and then the main task that processes them. I use progress and general properties that handle all updates.
Here is the code
public class TextSearch { final private SimpleDoubleProperty progress = new SimpleDoubleProperty(); final private SimpleDoubleProperty total = new SimpleDoubleProperty(); public Task<?> executeSearch() throws ZipException, IOException, JDOMException, InvalidTWXFile {
Using the main thread seems very awkward, and sometimes it freezes in this loop when searching for 10 + zip files at a time.
Is there a better way to do this with an unknown amount of tasks? Is there something like a JavaFX ExecutorService where I can add a bunch of tasks, let it go and control progressProperty?
source share