This content has been marked as final.
Show 1 reply
-
1. Re: Timer warning
depl20982 Aug 23, 2005 6:07 PM (in response to adamw)Hi.
I was having the same problem with scheduled timers, I made a workaround for this behaviour; but I still need to know the cause of the warning.
The code to reproduce the WARN is:
public void startTimer() {
ctx.getTimerService().createTimer(0, 1000, "Hello World");
}
@Timeout
public void timeoutHandler(Timer timer)
{
System.out.println("* Received Timer event: " + timer.getInfo());
}
The workaround is:
public void startTimer() {
ctx.getTimerService().createTimer(0, "Hello World");
}
@Timeout
public void timeoutHandler(Timer timer)
{
System.out.println("* Received Timer event: " + timer.getInfo());
//Recreate the timer to avoid WARN
timer.cancel();
ctx.getTimerService().createTimer(1000, "Creating EJBs");
}
The fact is that I need to recreate the timer every time to avoid the WARN.
Is there one elegant solution to avoid the WARN?