> Hello everyone,
>
[quoted text clipped - 6 lines]
> users input and still make it an infinite loop which sleeps every few
> minutes. Plz help me out I am really stuck at this situation.
There are a couple of ways to do this, but one of the
more flexible is to use two threads: One to do the repetitive
work, and one to wait for user input. The repetitive thread
does its parcel of work and then waits for notification that
input has arrived, using the wait(long) method to specify a
timeout. Upon awakening, it can check whether it's received
an input notice or has timed out. (It may also awaken for no
good reason, so if there's no input you should probably check
System.currentTimeMillis() to see if enough time has passed.)
Meanwhile, the input thread simply reads user input, taking
as long as it takes. When something arrives, it sets the "input
is here" indicator and calls notify() or notifyAll() to awaken
the repeating thread.
There are, as I say, other ways to do this. Some of the
other ways may be better suited to your situation -- but you
haven't told us much about your situation, so I've described an
approach that should cover pretty much everything, although it
may be more involved than you need.

Signature
Eric Sosman
esosman@acm-dot-org.invalid
Daniel Pitts - 15 May 2007 23:18 GMT
> > Hello everyone,
>
[quoted text clipped - 31 lines]
> Eric Sosman
> esos...@acm-dot-org.invalid
Actually, I'd go further than suggesting two threads, and suggest
using the java.util.Timer class. The Timer class starts up its own
thread, and manages that for you. One less thing to worry about.
Instead of awakening the timer thread on a user request, why not
simply do the thing that the user requests!
Mithil - 18 May 2007 12:49 GMT
HI,
Thanks guys I needed to get a starting point of somewhere. I think I
should be able to manage from now on cheers again guys and thanks for
replying this quick.
Mithil