db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oyvind.Bakk...@Sun.COM
Subject Re: [jira] Commented: (DERBY-31) Statement.setQueryTimeout() support.
Date Thu, 23 Jun 2005 12:19:32 GMT
Daniel John Debrunner wrote:
> 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.

No, scheduling an already used TimerTask will generate an 
IllegalStateException if any of the following are true (I have verified 
this):
a) the task has been scheduled but has not yet been run
b) the task has been scheduled and has been run
c) the task has been scheduled and has been cancelled

In other words, TimerTask objects can be scheduled only once, they can 
not be reused.

I suggest that I write a comment about this in the code in a subsequent 
patch (for instance when implementing Statement.cancel), unless anybody 
wants me to address this now and submit a new patch.

-- 
Øyvind Bakksjø
Sun Microsystems, Web Services, Database Technology Group
Haakon VII gt. 7b, N-7485 Trondheim, Norway
Tel: x43419 / +47 73842119, Fax: +47 73842101

Mime
View raw message