Create a time out for a polling loop
800306Mar 9 2009 — edited Mar 10 2009Hi,
I have a method call that starts an infinite loop that checks the status of some flag, and returns when the flag is set to true. However, I'd like the method call to return after a certain period of time, say five seconds; essentially a time out. I haven't been able to figure out how to implement this though.
I tried looking at something like java.util.Timer but that doesn't really seem to work; it seems as if the purpose of Timer is to schedule tasks. Whenever I search for ideas it just comes up with stuff about network connections timing out or whatever.
Can someone please give me an idea of how to go about implementing this?
Thanks