commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <mt...@apache.org>
Subject Re: [daemon] : Procrun problem
Date Fri, 08 Oct 2010 18:07:35 GMT
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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message