Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Watching a directory for new files

Mikolaj Rydzewski

2007-01-16

Replies:

David Kerber wrote:
> Thanks for the suggestion. One question about this technique: can I
> run the directory check loop directly in the contextInitialized event
> of the Listener, or is it mandatory to create a new thread?
You can't make an infinite (almost) loop during processing an event.
Using threads is discouraged ;-)

I'd suggest you to use javax.management.timer.Timer class instead. You
will not start another thread yourself, you will be notified at
specified intervals to check the directory, etc. Another option is to
use quartz to schedule directory checking events.

--
Mikolaj Rydzewski <miki@(protected)>


Attachment: smime.p7s
©2008 junlu.com - Jax Systems, LLC, U.S.A.