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

Query from Single Thread Model

 
VijayGanesh Thandeeswaran
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Query:

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
A Local and Request Variables
B Local,Instance and request variables
C Local,Instance,request,class variables
D None of these
please help me.....i heard that STM is not safe.
According to that statement My Choice is 'D' is it correct....
Regards.
T.Vijay Ganesh
 
Sarat Koduri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

please help me.....i heard that STM is not safe.
According to that statement My Choice is 'D' is it correct....


i am afraid you have choosen the wrong option..!!

Usually Request and Local varibales are always atleast in most cases are Thread safe and since you are using STM, the instance variables will also be Thread safe.

But in any case the session, Context and Class variables are NOT Thread safe.

so the option B is correct.

Hope i put it in a right way.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please read this
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As that link points out, only request variables are thread safe if you implement STM

Local variables are always accessible by one instance, so are also thread safe.

Instance and class variables are not thread safe even if one implements STM.

Hope that helps!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic