tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Smith <BSm...@pks.ie>
Subject RE: How tomulti thread a servlet
Date Mon, 14 May 2001 14:08:07 GMT
Thanks Danny,

You were correct... I misunderstood that servlets were singletons (only one
per system)
but I also recall warnings about keeping them thread safe. However, I tested
it with
a long running transaction ... and it servers more than one ... just fine.

-Bob



-----Original Message-----
From: Danny Angus [mailto:danny@thought.co.uk]
Sent: Monday, May 14, 2001 12:56 PM
To: tomcat-user@jakarta.apache.org
Subject: RE: How tomulti thread a servlet


I'm nervous about airing my own ignorance here, but what I have seen is that
Tomcat hands out requests to multiple threads each of which contains an
instance of your servlet.

In other words if your servlet processes the request Tomcat will run
multiple threads of it where necessary, by default.

These threads arent destroyed when the request is finished, but re-used (as
far as I know, which ain't far on this topic) for  more requests. Like the
apache httpd processes, and like them I believe (again I'm no expert) you
can set min spare and max spare to tune performance.

d

> -----Original Message-----
> From: Bob Smith [mailto:BSmith@pks.ie]
> Sent: Monday, May 14, 2001 12:24 PM
> To: tomcat-user@jakarta.apache.org
> Subject: How tomulti thread a servlet
>
>
> Hi,
>
> I have migrated a TCP based server to a servlet and cannot figure
> out how to
> get multi-threading working.
>
> The TCP server works like this;
>
> Listen for Request:
> read command code from the accepted socket;
> find a free thread containing a slave server who can handle the command;
> hand the socket over to the freeserver and interrupt the thread
> (the slave server reads and writes to the handed-over socket)
> Listen for next request
>
> What happens when I put this into a servlet is this;
> doPost is invoked
> find a free thread containing a slave server who can handle the command;
> get inputstream (from request) and outputstream (from response) and
> hand these streamsover to a free server thread and interrupt the thread
> doPost finishes
>
> I think what happens next is that Tomcat completes the request cycle,
> including
> closing the socket( and associated request/response stream)
> thereby screwing
> over the slave thread still process the command code.
>
> I want Tomcat to leave these streams alone and be ready to invoke the
> servlet
> for the next request. Is there support for this kind of stuff in Tomcat?
>
> Thanks
> -Bob
>
>
>
> **********************************************************************
> Privileged, confidential and/or copyright information may be contained
> in this e-mail. This e-mail is for the use only of the intended
> addressee. If you are not the intended addressee, or the person
> responsible for delivering it to the intended addressee, you may not
> copy, forward, disclose or otherwise use it or any part of it in any
> way whatsoever. To do so is prohibited and may be unlawful.
>
> If you receive this e-mail by mistake please advise the sender
> immediately by using the reply facility in your e-mail software.
>
> PKS Systems Integration (Ireland) Limited may monitor the content of
> e-mails sent and received via its network for the purposes of ensuring
> compliance with its policies and procedures.
>
> This message is subject to and does not create or vary any contractual
> relationship between PKS Systems Integration (Ireland) Limited and you.
> **********************************************************************
>
>


**********************************************************************
Privileged, confidential and/or copyright information may be contained
in this e-mail. This e-mail is for the use only of the intended
addressee. If you are not the intended addressee, or the person
responsible for delivering it to the intended addressee, you may not
copy, forward, disclose or otherwise use it or any part of it in any
way whatsoever. To do so is prohibited and may be unlawful.

If you receive this e-mail by mistake please advise the sender
immediately by using the reply facility in your e-mail software.

PKS Systems Integration (Ireland) Limited may monitor the content of
e-mails sent and received via its network for the purposes of ensuring
compliance with its policies and procedures.

This message is subject to and does not create or vary any contractual
relationship between PKS Systems Integration (Ireland) Limited and you.
**********************************************************************



Mime
View raw message