member variables in Job subclasses

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

member variables in Job subclasses

Nathaniel Auvil
Just want to be certain of this....

If i add a member variable to on of my Job subclasses, I do not have to worry about other threads sharing the same instance.  In clearer terms,  my understanding  of how Quartz works is upon a Trigger firing, the scheduler will use the class name from the job to call the no argument constructor on your Job implementation.  It will then call the: execute( JobExecutionContext jobContext ) on said instance.  When that method returns and the scheduler does its house cleaning, the Job instance will be destroyed...not pooled for reuse.

So i am free to create/assign local variables on my Job implementation without fear of other threads using the same instance.


Reply | Threaded
Open this post in threaded view
|

Re: member variables in Job subclasses

James House

Unless you're using a JobFactory other than the default, the default's
behavior is to create a new instance of your job class for each
execution, hence it would be thread safe.

james


On 07/19/2010 12:59 PM, Nathaniel Auvil wrote:

> Just want to be certain of this....
>
> If i add a member variable to on of my Job subclasses, I do not have
> to worry about other threads sharing the same instance.  In clearer
> terms,  my understanding  of how Quartz works is upon a Trigger
> firing, the scheduler will use the class name from the job to call the
> no argument constructor on your Job implementation.  It will then call
> the: execute( JobExecutionContext jobContext ) on said instance.  When
> that method returns and the scheduler does its house cleaning, the Job
> instance will be destroyed...not pooled for reuse.
>
> So i am free to create/assign local variables on my Job implementation
> without fear of other threads using the same instance.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]