I have this problem.
I need to have a method repeated endlessly, if possible, but without overloading the system.
As I understand, while(true) { …code… } will hang the system.
What would you suggest me to use which won’t hang the system?
Thanks
Also:
The execution of a my method may take up to 5 minutes, or 50 milliseconds, and I want method to be repeated jsut when it is finished
You could start a new Thread and run the task in the background. See the Java concurrency tutorial for more info.
If you only want to run 1 Thread for this task at a time, you could do it with a single thread executor.