Oyvind Bakksjo (JIRA) wrote:

> Hi Dan, thanks for reviewing this patch so quickly.
> 
> I am fully aware of and share you concern for the performance impact of 
> creating all the TimerTask objects.
>
> It is far from ideal.
> The problem is that the Timer class _forces_ recreation of TimerTask objects, 
> since these can't be reused;
> when a TimerTask has run or been cancelled, it is pure waste. Trying
to schedule the same task again will
> cause an exception. If it wasn't for this, we could associate a TimerTask 
> with each StatementContext object.

This is the kind of case where a comment in the code helps a great deal.
A comment that says why a new TimerTask is created each time due to the
requirements of the Java timer scheme. Not everyone will know or
remember restrictions on TimerTasks. Ane when I looked at the JDK 1.4
javadoc it wasn't clear to me that that was the intention of the scheme.
The implication TimerTasks can not be re-used is hidden the exception
description for adding one to Timer. I would almost read the javadoc as
you can re-use timer tasks, but a timer task can not be scheduled
multiple times concurrently.

Dan.



Reply via email to