How to write contineous application in java?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sujit_Sheth
Posted On:   Wednesday, June 12, 2002 04:46 AM

I want to write an application which will run constantly?

Can anybody help me out in that?
Thanks in advance.
Sujit

Re: How to write contineous application in java?

Posted By:   Simon_Ablett  
Posted On:   Wednesday, June 12, 2002 05:00 AM

An application that runs continuously is simply one that never returns control to the OS. Simply add a 'while(true)' contruct in your main method. Then make sure that it never calls 'System.exit()', never returns from the 'main' method and never throws a 'RuntimeException'. Of course, this won't stop someone else killing your process from the operating system ;-).

Example.


import java.io.*;

public class MyClass
{
public static void main( String [] args )
{
while(true)
{
System.out.println("Still alive");
}
}
}

I have a feeling that you might have had something else in mind than this(!!!??!?!?!).

Regards.
About | Sitemap | Contact