How about have your TimerTask set a flag in your Plugin when its running,
then in your Plugin.destroy() method, cancel the timer and wait until any
running task is finished.
public class MyPlugin implements Plugin {
public void setTaskRunning(boolean taskRunning) {
this.taskRunning = taskRunning;
}
public void init(ActionServlet servlet, ModuleConfig config) {
timer.schedule(new MyTimerTask(this), .......);
}
public void destroy() {
Timer.cancel();
while (taskRunning = true) {
wait(1000);
}
}
}
----- Original Message -----
From: "Guifre" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 23, 2004 10:10 AM
Subject: PlugIn TimerTask
> Hello,
>
> I have implemented an automatic process in
> Struts/Tomcat by starting a Timer and scheduling a
> TimerTask in the init() method of a PlugIn class.
>
> It works pretty well, except for one thing: if I stop
> Tomcat while the task is running, according to the
> Timer specification the task should be allowed to
> finish, but in fact it is ended in the middle of its
> process.
>
> Is this a Struts effect? Can someone figure out how to
> fix this?
>
> Thanks!
>
> Guifre
>
>
> ___________________________________________________
> Yahoo! Messenger - Nueva versi�n GRATIS
> Super Webcam, voz, caritas animadas, y m�s...
> http://messenger.yahoo.es
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]