Hi,
the problem here seems to be this..
the variable SuperCounter is being accessed by multiple threads which are
trying to change its value simultaneously (assuming you have more than one
request at a time since more than one instance of the singleThreadModel is
created...)
I think if you try to synchronize the variable SuperCounter your problem
may get solved...
but there is a race condition in the code
++SuperCounter;
sessionId=SuperCounter;
for example thread A may come and increment SuperCounter and then Thread B
may also increment SuperCounter before thread A has a chance of assigning it
to the sessionID..
try to reimplement it as sessionID = ++SuperCounter;
I think this should solve your problem..
regds,
Gokul
----- Original Message -----
From: "rachid" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 09, 2000 1:15 AM
Subject: SingleThreadModel and inheritance problem
> Salut tout le monde,
>
> I've problemes whith servlets that implements singlethreadmodel and
> extends a superservlet (which holds static reference to a database)
> it seams that i've more singlethread-servlets initialized and the static
> variable is initialized by the first singlethreadservlet but each
> client connect the same servlet :
>
> public class SuperTargot extends HttpServlet {
> protected static int SuperCounter = 1000;
> protected static Sconn Accessor=null
>
> public void init(ServletConfig config) throws ServletException
> {
> super.init(config);
> if (Accessor == null)
> first time stuff
> else stuff
> }
>
> }
>
> public class Targotin extends SuperTargot implements SingleThreadModel
> {
> private TSession session=null;
> int sessionId=0;
>
> public void init(ServletConfig config) throws ServletException
> {
> super.init(config);
>
> ++SuperCounter;
> sessionId=SuperCounter;
> session=new TSession(sessionId);
>
> public void doGet(HttpServletRequest request, HttpServletResponse
response)
> throws ServletException, IOException
> {
> stuff ,stuff ............................................
> out.println("<H2> Session ="+session.sessionId+" </H2>");
> }
>
>
> }
>
>
> the output is always the same (the last initialized servlet) for all
clients
>
>
> I am running apache ApacheJServ-1.1.1-2 on a linux box with jdk1.2
>
> and the zone properties file contain the line
> tz.properties: singleThreadModelServlet.initialCapacity=15
>
> Any Suggestions would be nice
>
> merci et excusez mon anglais merveilleux
>
>
___________________________________________________________________________
> 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
___________________________________________________________________________
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