tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Mack <C.M...@austria.eu.net>
Subject Tomcat & SingleThreadModel?
Date Wed, 24 May 2000 15:29:19 GMT
Hello!

I have Tomcat 3.1 installed on a x86 SuSE 6.3 Linux. I implemented the
following very simple servlet:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
public class Loop extends HttpServlet
       implements SingleThreadModel
{
    int global;

    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
           throws ServletException, IOException
    {
        int j;
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        for(j=0;j<1000000;j++) {
          out.println(global++);
        }
    }
}

Next I startet two WebBrowsers to connect to my servlet. I expected
Tomcat to create two servlet instances (one for each GET-reqest) and
thought output will be generated and displayed concurrently.
But what really happened is that the second request was obviously NOT
served concurrently. The second WebBrowser started to display data AFTER
the first WebBrowser finished.
What went wrong???

If I recompile the Loop class without the SingleThreadModel the output
IS generated concurrently but of course the requests influence each
other because the access to variable global is not synchronized.


Maybe there is a variable that must be set in the web.xml file (or
somewhere else) to declare the maximum number of servlet instances which
may be created by tomcat...

please help
thank you
  X-toph

Mime
View raw message