Sunday, 8 September 2013

Stop java service with sepatare stop class using javaservice.exe

Stop java service with sepatare stop class using javaservice.exe

How make a separate stop class for stop my service? I have a class that
use a timer for run a tast each second. I use javaservice aplication for
install the service with my main class as a start class but i don't know
how have to implement the stop class.
this is mi java class that run as a not service.
public class Timer{
Timer timer = new Timer();
public int segundos;
public boolean frozen;
class MiTarea extends TimerTask {
public void run() {
segundos++;
}
}
public void Main(String[] args) {
frozen = false;
try {
timer.schedule(new MiTarea(), 0, pSeg * 1000 * 60);
} catch(Exception e){}
}
//this method have to be in other stop class???
public void Stop() {
frozen = true;
}
}

No comments:

Post a Comment