tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Achilleus Mantzios <>
Subject Servlet wierd threading behaviour in tomcat 4.0.1
Date Fri, 22 Mar 2002 07:04:07 GMT
firstoff my excuses for posting to the developer list,
but unfortunately user-list didnt shed some light on the issue.
So here it is :)

I have seen a strange threading behaviour in catalina engine.
For servlets that
a) Dont implement SingleThreadModel
b) Dont synchronize over resources
c) Dont have service methods synchronized,

the server serves 2 concurrent requests to 2 clients requesting the same URL
Suppose the following servlet is mapped to /servlet/ThreadTest.

When i invoke from 2 clients
http://myserver/servlet/ThreadTest?foo1=bar1&foo2=bar2 and
http://myserver/servlet/ThreadTest?foo2=bar2&foo1=bar1 respectively

the server seems to spawn 2 threads running the service method of the servlet
as expected.

However when a invoke the follwing 2 urls (or in general IDENTICAL URLS)

http://myserver/servlet/ThreadTest?foo1=bar1&foo2=bar2 and
http://myserver/servlet/ThreadTest?foo1=bar1&foo2=bar2 respectively

then the threads (thread?) run as if i had synchronized the service method.

This looks like a bug, here is the source of the simple servlet.

The servlet is as follows....
import javax.servlet.*;
import javax.servlet.http.*;

public class ThreadTest extends HttpServlet {  
    public void init(ServletConfig config) throws ServletException {

    protected void processRequest(HttpServletRequest,HttpServletResponse 
    throws ServletException, {
        System.out.println("In the begin damnit");
        try {
        catch (Exception e) {}

    protected void doGet(HttpServletRequest request, HttpServletResponse 
    throws ServletException, {
        processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse 
    throws ServletException, {
        processRequest(request, response);

Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
tel:    +30-10-8981112
fax:    +30-10-8981877

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message