On 10/07/2010 08:44 PM, Megha Bhopale wrote:
Hi, I am facing one problem while registering my jar application as windows service using Procrun. I hava a main class and a TimerTask class. I am initiating TimerTask from main class as below. public class mainClass{ public static void main(String[] args){ if ("start".equals(args[0])) start(); if ("stop".equals(args[0])) stop(); }public void start(){ mTimer=new Timer(); timer.schedule(new myTimerTaskClass(),60000); } public void stop(){ mTimer.cancel(); } } public class myTimerTaskClass(){ public void run(){ System.out.println("Here repeats the timer"); } }
Which version of procrun you are using? Your code main method returns immediately, so earlier procrun versions will just think the application is done. Anyhow, I'd suggest that you actually wait inside main() that JVM exits (your worker threads), do eventual cleanup and then return from the main method. The upper code is just a Java "hack" which allows the JVM to continue working even if the main entry method exited. And this should be forbidden by the law, if you ask me ;) Regards -- ^TM --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
