commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "None None" <japp...@hotmail.com>
Subject How to write app class for proc run?
Date Thu, 07 Oct 2004 14:31:57 GMT
So far I have this... But I cant seem to get it to stop when I execute it...

Thanks

public class Executer
{
	private static Executer daemon = null;
	private boolean state = false;

	public static void main(String[] args)
	{
        if(daemon == null)
        {
            daemon = new Executer();

			try
			{
            	daemon.init();
            }
			catch(Throwable t)
			{
				t.printStackTrace();
				return;
            }
        }

		if(args.length > 0)
			if(args[0].equals("start"))
				daemon.start();
			else if(args[0].equals("stop"))
				daemon.stop();
	}

	public void init()
	{
		state = true;
	}

	public void start()
	{
		while(state)
		{
			System.out.println("Running...");

			try
			{
				Thread.sleep(1000);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}
	}

	public void stop()
	{
		state = false;
	}

}

_________________________________________________________________
Scan and help eliminate destructive viruses from your inbound and outbound 
e-mail and attachments. 
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines

  Start enjoying all the benefits of MSNŽ Premium right now and get the 
first two months FREE*.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message