Automating task using recursive threads
I have to write a program which reads from a text file sequentially some commands line by line. It then uses the read command information to make a call to another methods with respect to what command it has read from the file.
This is for automating the movement of a vehicle using a script file.
So my text/script file can be like the following:
START /*start of the file*/
Q /*turn left*/
A20 /*Accelerate for 20 seconds*/
W /*Make wheels straight*/
END /*end of the file*/
So I need a timer for addressing the command A20, since I have to accelerate the =vehicle for 20 seconds..
I want this thread which is reading from the file to wait but the background thread to run so the vehicle keeps on moving for the 20 seconds time. And only after the vehicle has finished movement, I want to read the rest of the file and interpret the other commands.
I had tried using java timer but ended up with the timer threads not getting killed at the end..
Any ideas on how to do this?
Thanks in advance