aspose file tools*
The moose likes Servlets and the fly likes SingleThreadModel interface - deprecated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SingleThreadModel interface - deprecated" Watch "SingleThreadModel interface - deprecated" New topic

SingleThreadModel interface - deprecated

Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
SingleThreadModel interface has been deprecated in J2EE 1.4.

The reason as I understand from the docs is:

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.

I wonder why this realisation only in Servlet 2.4? I always thought this was a problem even in the previous versions.

Finally Sun is not recommending the use of SingleThreadModel.
Arto Pastinen
Ranch Hand

Joined: Dec 13, 2002
Posts: 79
heh.. quite funny.

Maby next Sun will recommend not to use clustering, beacause there is no support to lock session between nodes..
I agree. Here's the link:
subject: SingleThreadModel interface - deprecated
Similar Threads
Single Thread Model
Single Thread Model
Doubt in Thread Safe Servlet.
Is Sessions thread safe if servlet implement SingleThreadModel interface ?
Multiple instances and multiple threads