Java - 'continue' loop iteration after certain timeout period
- by Matt
Is there a way to exit ('continue;') a loop iteration after a certain timeout period?
I have a loop that will run gathering data from the web and then use this data to make a calculation.
The data become obsolete after about 1 to 2 seconds so if the loop iteration takes longer than 1 second then i want it to 'continue' to the next iteration.
Sometimes gathering the data can take time but sometimes the calculation can take longer than 1 second so a HTTP timeout won't work for what i need.
Also, while doing the calculation the thread i am using is blocked so i cannot check System.currentTimeMillis();
Is there a way to use another Thread to check the time and force the original for loop to continue.