B
Big Jim
Guys, I've a loop where I receive a prompt when I need to go to the DB,
check if there's anything I need to process and if there is, process it.
I also want to poll periodically if I don't get a prompt within a certain
time period in case the prompt has failed for any reason. I'm currently
using this logic:
// listener is the thread that listens for prompts
// "this" is also a thread allowing the listener to interrupt us when it
gets a prompt
listener.initialise(this);
listener.start();
while(true)
{
try
{
Thread.sleep(pollSeconds * 1000);
}
catch(InterruptedException ex)
{
log.info("Interrupted ...");
}
publisher.doProcessing();
}
So, basically I'm using the Interrupted exception to break out of the sleep
early.
What I'm wondering is whether this is a poor way to do this as I'm using the
exception handling mechanism for normal processing i.e. it's not an
exceptional situation. Is this poor? Is there a more standard way to do
this?
Thanks, Richard.
check if there's anything I need to process and if there is, process it.
I also want to poll periodically if I don't get a prompt within a certain
time period in case the prompt has failed for any reason. I'm currently
using this logic:
// listener is the thread that listens for prompts
// "this" is also a thread allowing the listener to interrupt us when it
gets a prompt
listener.initialise(this);
listener.start();
while(true)
{
try
{
Thread.sleep(pollSeconds * 1000);
}
catch(InterruptedException ex)
{
log.info("Interrupted ...");
}
publisher.doProcessing();
}
So, basically I'm using the Interrupted exception to break out of the sleep
early.
What I'm wondering is whether this is a poor way to do this as I'm using the
exception handling mechanism for normal processing i.e. it's not an
exceptional situation. Is this poor? Is there a more standard way to do
this?
Thanks, Richard.