Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SingleThreadModel Mock Question

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose that Myservlet implements SingleThreadModel.
and there are
Local variables
Instance variables
Class variables
Request attributes
Session attributes
Context attributes
Which among these variables would be thread safe
Select any one
A Local and Request Variables
B Local,Instance and request variables
C Local,Instance,request,class variables
D None of these
I donot know the correct answer but I think it shud be A
Can anyone correct me if I am wrong?
 
Sam Cala
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it should be B
When you gonna take the exam, Gaurav ?
 
Tong Chen
Ranch Hand
Posts: 1011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you give a little more explanation?
Thanks,
 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Local variables will be ridded of by the time the method returns so there's no worrying about other threads.
From the servlet specification (regarding static variables):
"The SingleThreadModel interface does not prevent synchronization problems that results from servlets accessing shared resources such as static class variables or classes outside the scope of the servlet".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic