You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Tyn T. Ong" <tt...@myrealbox.com> on 2003/08/15 08:42:59 UTC
Attaching File Monitor Thread to Tomcat
Hi all,
I'm trying to develop a Thread (I call it Monitor) which monitors a folder
for FTP uploaded files (arbitrary upload interval) and parse them to DBMS.
I would like to start and stop that Monitor Thread with tomcat so I loaded
from a (load-on-startup) servlet. It loads OK and works fine but when
Tomcat shuts down, it doesn't wait for my Thread to cleanup.
I tried in Servlet destroy method...
Monitor.stopNow(); // my thread polite stop method
while(Monitor.isAlive()); // wait until thread's while loop exists
in servlet destroy method but tomcat forcefully unload before
Monitor thread can clean up.
I also tried overriding finalize() method but it was never called :-(
Any ideas??
Thanx,
Tyn
PS: It would be great if tomcat has standard API to attach/control other
Java Server/Daemon process. If developers reading this, please consider my
request.