On Thu, 12 Apr 2001, 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:
[ ... ]

As has been posted, using SingleThreadModel is a bad idea.  There has
been a lot of discussion of it on Sun's servlet-interest list.  For
one thing, it does not allow you to not have to worry about threading
issues.  In this way, it is quite misleading.  It only really protects
you from certain kinds of threading issues, it is far from a cure-all.
And it has perforamnce implications, as you've seen.

You can't really avoid dealing with concurrency issues in Java.  The
best thing to do is to just bite the bullet, learn what you need to
about concurrency, analyze your code, and make it handle it as
best/easily as possible.  Avoid concurrency issues as much as
possible, and when unavoidable, limit it to the smallest block
possible and synchronize it.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

Reply via email to