• Post Reply Bookmark Topic Watch Topic
  • New Topic

isThreadSafe is false for Single Thread Model?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Referring to page 313 of HFS&J:

If 'isThreadSafe' attribute of 'page' directive is false, it means, you want to use Single Thread Model.

My doubt is, regardless of how bad Single Thread Model is, STM is always a thread safe implementation.

Then why for STM, isThreadSafe is false???

Hope my point is clear.
[ May 21, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prior to its deprecation, the only reason to use the SingleThreadModel was because your code was not thread-safe. Ergo, isThreadSafe would be false.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Prior to its deprecation, the only reason to use the SingleThreadModel was because your code was not thread-safe. Ergo, isThreadSafe would be false.


Is it like, if 'isThreadSafe' is false means, we want to implement STM or it is STM???

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is set to false, then the resulting code will implement STM. The servlet engine does all that - no further action by the developer is required.
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isThreadSafe is deprecated although for earlier versions of JSP,
By default isThreadSafe is "true" indicatinf no STM is implemented by genarated Servlet where as if one sets it to false then effect of implementing a STM used to achieve.
As STM itself is deprecated hence the isThreadSafe attribute as well.

By chance if you are using Tomcat you can see the code of genrated servlet. (For true & false values of isThreadSafe)

I don't know why Sun people has kept such ambiguous meaning of this attribute (Normally People think isThreadSafe is true means it will be threadsafe i.e.Servlet will be implementing STM)

great thing that ultimately they removed it...Normally you don't need to change default meaning of thus attribute

Shriniwas
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
If it is set to false, then the resulting code will implement STM. The servlet engine does all that - no further action by the developer is required.


Yes, doesn't it look strange.
isThreadSafe is false, the meaning of this line is, the code is not thread safe. BUT the code will implement Single Thread Model and that is THREAD SAFE.

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the code is still not thread-safe. It is executed in a thread-safe manner, which is different.
 
Peter Hu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to understand this directive in the correct context. It doesn't use it in the context of the servlet container but the developer. If you set it to true, it means you - the developer - understand the burden is on yourself to quarentee to write it thread safe; if it's false, that means you don't have to write thread safe code, the container does it for you.

Also the implemntation is up to the servelt container's vendor. STM is not dictated here. You can synchronize the incoming requests instead.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul HG:
You have to understand this directive in the correct context. It doesn't use it in the context of the servlet container but the developer. If you set it to true, it means you - the developer - understand the burden is on yourself to quarentee to write it thread safe; if it's false, that means you don't have to write thread safe code, the container does it for you.

Also the implemntation is up to the servelt container's vendor. STM is not dictated here. You can synchronize the incoming requests instead.


Could be a good way to remember the things.

Thanks.
 
Ramasubbhu Allur Kuppusamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rathi Ji :

Could be a good way to remember the things.


As a matter of fact, it is meant to be understood that way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!