This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HFSJ Mock Exam

 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By making doGet() of HttpServlet synchronized it will make ServletRequest Attribute Thread Safe.

True or false

Thanks
Srividhya
 
Paul Brabban
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Attributes of ServletRequest are thread-safe anyway (how would you access an attribute in request scope from another thread?) so no, synchronizing doGet won't make any difference.

Cheers,

Paul
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul This statement is given as true in the HFSJ mock exam. So just wanted to clarify.

Srividhya
 
Baddy Davay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that should be true.The reason behind that is ,request attribute can be accessed only from the doXXX methods ,So all the requests mapped to the doXX methods with doXXX methods synchronized obviosly by the Java Rule makes the method thread safe ,and hence makes the attributed accessed or updated as well thread safe.
Correct me if I am wrong
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!