tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Kilbride" <j...@kilbride.com>
Subject Re: Servlet -- SingleThreadModel
Date Fri, 13 Apr 2001 01:50:27 GMT
That's the whole point of SingleThreadModel, ensuring only one request
accesses a given servlet instance at any one time. Check the javadoc:

http://tomcat.mslinn.com/jsp22_servlet11/index.html

To handle more than one request at a time, the servlet container uses a pool
of instances of the servlet that implements the SingleThreadModel interface.
However, if your "Connection" resource, the one you're trying to
synchronize, can only be used by one servlet instance at a time,
SingleThreadModel pooling is not going to help you. The servlet instances in
your pool are going to "line up" behind the one currently using your
"Connection" resource.

What kind of "Connection" are you trying to synchronize? Are you limited to
having only one "Connection" at any one time? If so, your bottleneck is your
"Connection" resource and not the SingleThreadModel interface.

Maybe if you post some of your code, we can help you figure out a better way
to implement it.

Thanks,
--jeff

----- Original Message -----
From: "eric leung" <chiu02us@yahoo.com>
To: <tomcat-user@jakarta.apache.org>; <dave@convio.com>
Sent: Thursday, April 12, 2001 5:12 PM
Subject: Re: Servlet -- SingleThreadModel


> David,
> Thanks your suggestion.
>
> But I don't think this is a good solution. i have
> already 50Kb of code in that servlet class. if i need
> to move it to another class. that will be alot of
> work.
>
> My question is why implement SingleThreadModel
> interface can't handle more than 1 request at a time?
> Since i will have only 3 clients. I think
> SingleThreadModel is the best solution, without the
> need to worry about threading issue.
>
>
> --- David Crooke <dave@convio.com> wrote:
> > Make your connection etc. stack variables instead,
> > by creating a class
> > to contain them and move all your code into that
> > class - then have the
> > empty servlet "new" an instance and call the service
> > method. This way
> > you can use instance variables and the
> > Multi-Threaded Model.
> >
> > eric leung wrote:
> >
> > > I have a servlet implements the SingleThreadModel
> > > Interface. But this servlet has problem handle
> > more
> > > than 1 request at a time.
> > >
> > > Since I have 1 person on host1 upload a big file (
> > >
> > > 20MB ) to the servlet.  When the 2nd person on
> > host2
> > > send a request to that servlet. The servlet will
> > not
> > > response.
> > >
> > > Any one had the same problem using
> > SingleThreadModel?
> > > I am using apache 1.3.17 + tomcat 3.2.1.
> > > thanks.
> > >
> > > P.S. I use SingleThreadModel beause i don't want
> > to
> > > worry about syncronization of threads, I have
> > > Connection as instance variable:
> > >
> > > public class admin extends HttpServlet implements
> > > SingleThreadModel{
> > >   private PrintWriter out;
> > >   private OracleConnectionCacheImpl pool;
> > >   private Connection conn;
> > >   private Statement stmt;
> > >
> > >   ..etc...
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get email at your own domain with Yahoo! Mail.
> > > http://personal.mail.yahoo.com/
> >
> > --
> > David Crooke, Chief Technology Officer
> > Convio Inc. - the online partner for nonprofits
> > 4801 Plaza on the Lake, Suite 1500, Austin TX 78746
> > Tel: (512) 652 2600 - Fax: (512) 652 2699
> >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
>


Mime
View raw message