"Emuleomo, Olu (PME)" wrote:

>         >>>In my opinion Sun made a mistake when including the STM model.
> Essentially
> >>>it encourages stupid people to stay stupid
>
> Dont be so harsh!  Many many programmers find it hard to write
> multi-threaded code.
> Dont forget that not all pgmrs have degrees in Computer Science!
>
> --Olu E.

I agree with Jon that STM is a bad thng.

All harshness aside, there are multi-thread issues that SingleThreadModel does
not address.  Programmers that rely on it because they don't know how (or don't
want to know how) to write multi-thread-safe code will usually get bit on one
or more of the following:

* Performance -- for toy projects, or during development, you often
    don't see this one, but it shows up when you put a multiuser app
    into production.  Partial solution -- configure your servlet engine for
    multiple instances, but this leads to the next problem.

* Information sharing -- 99.9% of new servlet authors seem to think
    that STM means there will be only one instance of the servlet, but
    that is not necessarily the case.  In particular, you solve some of the
    performance issues by telling your servlet engine to create more than
    one of them.  Even with STM, you can not rely on using instance variables
    in your class as globals.

*  Multiple users -- Even if STM solves particular programming issues
    for you, servlets operate in a multiple-user environment.  You still have
    to worry about things like two users modifying the same data at the
    same time.  You can't hide from multi-threading, and the requirement
    to properly synchronize access to shared objects.

STM encourages developers to believe that they don't have to worry about
multithreading.  This leads to disappointment and required redesigns when you
run into cases where your assumptions are violated.  Much better would be to
train new servlet programmers to program in a multithreaded manner from the
first moment.

This is where the experts have some responsibility -- we need to make sure that
the examples we create demonstrate thread safe techniques.  Servlet book
authors need to emphasize thread safety in their tutorials and explanations --
and demonstrate how to program it correctly.  Development managers need to
insist that thread-safe techniques be used on the projects they are building.
Above all, it is the responsibilty of API designers to avoid tempting people to
take the "easy" way out, without solving *all* of the related problems.

But new servlet developers have a responsibility also -- you need to commit
yourself to learning how to properly use the tools you are working with.
Otherwise, you will perpetuate the bad reputation that software developers
carry in the real world, for creating stuff that just does not work.

Craig McClanahan

___________________________________________________________________________
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