aspose file tools*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Single Thread Model" Watch "Single Thread Model" New topic
Author

Single Thread Model

Nikhil Bansal
Greenhorn

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

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

Regards

Nikhil
David O'Meara
Rancher

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.
 
 
subject: Single Thread Model