Monday, 29 October 2012

J2EE Links

J2EE Links

How to Make Servlet Thread Safe


There are two different ways of making a servlet thread 
safe namely

1.By implementing SingleThreadModel.

By implementing a SingleThreadModel it will be possible to 
create a Thread safe servlet.There can only be one user at 
a given point of time.

2.Synchornize the part of sensitive code.

We can allow a single user at a given point of time by 
making that part of the code which is sensitive as 
synchronized.
3.Do not instance variables into our servlet we use only 
local variables
 

Good description:
http://www.javaworld.com/javaworld/jw-07-2004/jw-0712-threadsafe.html