You can specify a class-static block that will get executed as soon as the
servlet is loaded into the JVM--you can't force it otherwise (except, of
course, by "priming" the Web server by hitting the servlet every time you
restart the Web server). Note that the Web server is also free to recycle
the servlet at any time, according to the spec, I believe.

public class Blah
{
    static
    {
        // This block of code gets executed as soon as Blah is loaded into
the JVM, for whatever
        // reason--it will get executed before anything else in the class;
see the JVM Spec or the
        // Java Lang Spec for details

        Thread t = new Thread(new SomeRunnableImplementation());
        t.start();
    }
}

Ted Neward
Patterns/C++/Java/CORBA/EJB/COM-DCOM spoken here
http://www.javageeks.com/~tneward
 "I don't even speak for myself; my wife won't let me." --Me

-----Original Message-----
From: Scheiderer, Stephan <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Saturday, July 24, 1999 10:56 PM
Subject: Background thread


>Hi,
>
>I�m using Apache 1.3.6 on NT 4.0... How do I assure that a background
thread
>that checks something is started when the server is started? Do I have to
>make a servlet that implements Runnable or is there another possibility
>except for starting a main() function with java.exe when the server is
>started? Or can I specify other exes to be launched at startup of the
>server?
>
>MfG Stephan Scheiderer - debis Systemhaus GEI
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to