Java Application Flow (pause & wait?)
Hello, I have several USB devices I've connected to a linux box which have available API's. I'm trying to write a java application to access them and gather data. My first attempt worked pretty well (or well enough) I just have a question about application flow. How do I make the program pause and wait for an event? and once the program has completed how do I make it restart and wait again? Below is the rough flow I'm trying to achieve:
Program Runs -> Wait for action (enter button, usb sensor doesn't matter) -> display thank you (wait 10seconds) -> restart process.....
Currently I'm using a while loop with Thread.sleep(100000); but I'm sure there is probably a better way to-do this. Once it runs I need it to just hang until a user input event has happened, and then how do I display a thank you message, wait 10seconds, and then restart it to where its waiting again?
Thanks in advance!
Re: Java Application Flow (pause & wait?)
Re: Java Application Flow (pause & wait?)
is there a way to-do it without a gui?
Re: Java Application Flow (pause & wait?)
Perhaps the Java Executor Interfaces could be applied here. This assumes that the USB APIs to which you refer can be used to notify you of an event which would be your trigger.