Hi
I dont know weather we can sleep in service method or not, but we are using
sleep call while servicing a request; from doPost etc and its working.
below is the definiton of a functon that creates a jdbc connection and if
its null, it sleeps and then wake up to try it again, untill it gets one
that is not null ;-)
----------------------------------------------------
public Connection createConnection()
{
Connection CConnection = null;
do {
CConnection = m_dbConnectionBroker.getConnection();
try {
if (CConnection == null) { Thread.sleep(4000); }
} catch (InterruptedException e) {BVLog.logError(e);}
} while (CConnection == null);
return CConnection;
}
---------------------------------------------------------
hope this will help
vaince
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of JOSE
ADRIANO BALTIERI
Sent: Monday, January 24, 2000 5:57 PM
To: [EMAIL PROTECTED]
Subject: Sleeping at the service (method) !
Hello list
I'm needing to wait or sleep or yield during the service method.
However, whenever I put a wait() in the middle of the service
method,
it seems that the transaction is interrupted and the browser receives an
empty document. It appears to me that the service method was abandoned.
Why do I need to do that ? Because the response is being provided
by
someone else, via a text file. So the servlet enters into a loop where it
will
wait for the existence of such a text file. If I don't signal the system
that
the servlet is idle, it will consume so much CPU that the benefits of
migrating from CGI to SERVLET as simply gone. This problem spoils all the
advantages I could have from the migration.
I also checked this mailing list archives and it was said before
that this is impossible to do.
As I can't believe it, I'm posting the question again.
So,
Is there a way to sleep during the service (method) ?
Could I use an external call to do that, say, a C program ? Would
that be acceptable (I'd prefer to do it natively, I mean, inside Java
itself).
Thanks for any kind of colaboration !
Obrigado/Thanks a lot,
Jose Adriano Baltieri
Analista de Sistemas
CPD - CENTRO
UNIMEP - Universidade Metodista de
Piracicaba
PIRACICABA - SP - BRASIL
Fone : 055 019 430-1858 (english spoken)
Fax : 055 019 430-1898 (Caixa Postal
42778)
___________________________________________________________________________
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