I'm working on a **Java** function that should be called **infinitely**. This function will call a **web service** that will **return** back results. Results are then **parsed** and **analysed**.

The function ***should not be called again*** until the web service returns results, and these results are **analysed**.

Should I be using infinite recursion to achieve this? Or should I be using a timer that calls the function on certain intervals?

Some questions arise as well:

1. What happens if the web service's response times out? How can I prevent the application from crashing or making unlimited calls with no response?
2. Should I be creating an event driven class to handle these requests?
3. In terms of optimization, which of the solutions is more efficient?

-- Edit

I understand the question is a bit vague and general, so non detailed answers will do just fine, I'll focus on the implementation. I just need an advice on the approach. :)

Any help is appreciated.