File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Single Thread Model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Single Thread Model" Watch "Single Thread Model" New topic

Single Thread Model

Nikhil Bansal

Joined: Mar 21, 2006
Posts: 21
Hi All,

Why is single thread model deprecated in the latest versions on Servlet API.


David O'Meara

Joined: Mar 06, 2001
Posts: 13459

From the API:

Note that SingleThreadModel does not solve all thread safety issues. For example, session attributes and static variables can still be accessed by multiple requests on multiple threads at the same time, even when SingleThreadModel servlets are used. It is recommended that a developer take other means to resolve those issues instead of implementing this interface, such as avoiding the usage of an instance variable or synchronizing the block of the code accessing those resources. This interface is deprecated in Servlet API version 2.4.

Baically to be thread safe you need to consider all threading issues, and since the Single ThreadModel doesn't really provide anything except a brute force attempt at this, it creates the illusion of thread safety and needs to go.
I agree. Here's the link:
subject: Single Thread Model
It's not a secret anymore!