Implement the SingleThreadModel interface (generally not a good solution) or
learn how to program in a multithreaded environment. This is not a subject
that can be answered in a couple of sentences (and, indeed, we just had a
thread (pun intended) on this interest group on threads - check the
archives.
Generally speaking (always dangerous), a thread-safe servlet is the result
of thoughtful reflection on the part of the programmer to realize that a
method or instance variable is going to be used by different requests
simultaneously. If that may occur, you must synchronize your method or
(preferably in a servlet) the variable in a synchronization code block.
Jason Hunter demonstrates this technique in the first 3 chapters of "Java
Servlet Programming" - 1st or 2d ed.). Nevertheless, you should read some
literature on programming with threads in Java - the java.sun.com website
has a great tutorial on it, but I don't know where it is right off hand.
I will say that multithreaded programming is an art, but with Java, it
involves watercolors; with C++ it involves oils.
Cheers!
Mark
----- Original Message -----
From: "Mahesh Davendran" <[EMAIL PROTECTED]>
Sent: Monday, April 23, 2001 7:33 AM
> Hi!
> could someone there give me an example on threadsafe servlets. Thanks.
>
> Regs,
> Mahesh Devendran
___________________________________________________________________________
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