• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

which is thread save

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
reply
    Bookmark Topic Watch Topic
  • New Topic