There are two concepts you have to understand: thread-safe and reentrant.


A method is reentrant, if many threads can enter the method as the same time without conflicting. For that you only have to act on parameters and local variables. Threads only share the data- and the code-segment of an application. Every thread gets his own stack-segment, where all local variables and the parameters will be push onto. If you act in the execute-method only on the parameters and on local variables you are thread safe. If you will join shared ressources as database connections ... you have to take care, that such ressources are either pooled or the access is sychronized.

So the message is: In the execute Method don't use global variables but only local variables. This and the parameters are pushed on your stack, that is only in your thread visible.

Hope it helps
Manfred Wolff


Jignesh Patel wrote:


Riyad,
But does this methods are synchronized? Otherwise if two threads execute at the same time they can access the method at the same time. And result will be big mess.


-Jignesh
On Monday 10 May 2004 18:29, Riyad Kalla wrote:


This question is actually what made me sign up to this mailing list...
the answer is that there is no implicit concurrency. All your
work/variables in Actions should be method-scoped and not use ANY class
variables because of this. My specific questions was that I wanted to
use a class variable "ActionErrors" so any of my methods
(DispatchAction) could add errors without initializing a new ActionError
instance, and return it. But this is incorrect and can/will introduce
problems.

So there is no concurrency in Struts.

Jignesh Patel wrote:


On Monday 10 May 2004 17:21, Jignesh Patel wrote:
I am just wondering, how concurrent request will be handled by single
Action class. Because for many form objects(as there are thousands of
browser running with jsp forms) and there is only one action class.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to