Is Servlet Class Thread safe?????? How to make servlet
Thread safe ???
Answer Posted / venkat
by default every servlet is not Thread safe.
if we want to make Thread safe use these statements
1) use SingleThreadModel interface . but this interface is
deprecated in servlet 2.5 specification
2) use synchronized methods and blocks
for example
=========
use synchronized method
=======================
public synchronized void service(ServletRequest
request,ServletResponse response) throws
ServletException,IOException
{
.........
.......
}
use synchronized block
========================
public void service(ServletRequest request,ServletResponse
response) throws ServletException,IOException
{
synchronized(this)
{
.........
.......
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is getservletcontext?
What are the steps that are involved in using the httpservlet class?
How will two or three servlets interact or communicate with each other?
What do you mean by chaining in servlet?
What is the difference between the http servlet and generic servlet?
What is servlet and its use?
Explain mvc pattern.
How the servlet is loaded?
What mechanisms are used by a Servlet Container to maintain session information?
How can a servlet be used to generate plain text instead of html?
Is servlet synchronized?
How is a servlet implemented in code?
What is servlet and its advantages?
Which method is called when reference variable is passed in system.net?
Why session tracking is needed?