I have this logic in my application:
1- Read trace file that has animation in Jmonkey format
2- From simpleApp execute the cinematic line by line and create the Jmonkey animation
However the trace file could have up to 300,000 lines (or events since each line is a specific event) meaning that doing so in one shot is not efficient as it would take me up to 5 minutes to load all the events and then start executing them. After the loading, the animation runs fine.
In order to improve the loading time, I was suggested to use threads (I have never used multithreading but I know the concept and read the advanced multi-threading tutorial). I was hoping if there’s a way to initiate the animation after reading the first chunk of the file and at the same time, using threads read the second chunk of it so I don’t have to wait for it. This shouldn’t be too hard as all the spatials are created at time 0, and the rest of the file just moves, rotates, and accelerate/decelerate those spatials.
So far my design is
Jme3Cinematics.java –> contain the animation main engine, createSpatials(), rotateSpatials(), accelerateSpatials() etc Adapter.java –> reads trace file and parses line by line and according to what’s read & calls the appropriate function from Jme3Cinematics class.
Question is how can I use multithreading to solve this issue? How can I divide the file into 2 parts (or probably more) and assign a thread for each?
Thanks!

New Topic/Question
Reply


MultiQuote







|