Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

which is thread save  RSS feed

 
salman ahmed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q-1)class ABC extends HttpServlert
{
AnyClass obj;
public void init()
{
Classboject obj=new Classboject();
}
}
Q-2)class ABC extends HttpServlet
{
public void get(HttpServletRequest req,HttpServletRequest res)
{
/*html required tags and session creation*/
synchronized(session)//any seesion created before
{
<form method=post>
inputtype=text name=one
inputtype=text name=two
</form>
}

public void post(HttpServletRequest req,HttpServletRequest res)
{
}
}
Q-1 IS OBJ IS SYNCHRONIZED.T/F
Q-2 IN Q-2 WHEN CALLING POST METHOD IN THE SAME CLASS THEN IT IS IT AUTOMATICALLY THREAD SAVE
T/F
Q-3 IN Q-2 if <form action=gotooherservlet method=post> i.e go to oher page then is that post method will be ThreadSafe
T/F



}
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1) you have two different references named obj. The AnyClass obj will not be Thread-safe.
Q2) The method names are doGet and doPost for a starter.
I can't make any sense out of your question.
Q3) Can't make any sense out of this one either.
Generally speaking - servlet instance objects may be accessed by more than one Thread at a time - ie NOT Thread-safe.
Local references, - declared inside doGet for instance - are Thread-safe.
Bill
------------------
author of:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!