java - why are struts Action classes not thread safe? -
i can read in many websites struts action classes not thread safe . not able understand why .
also read book says "struts action classes cached , reused performance optimization @ cost of having implement action classes in thread-safe manner"
how caching action classes , being thread safe related? .
how caching action classes , being thread safe related?
if cache , re-use instances of class, allowing multiple threads access same instance simultaneously, class inherently not thread-safe*. if place mutable instance or static fields on class, results under concurrency unexpected , problematic. on other hand, if each thread has own instance of class, class inherently thread-safe.
- struts 1 action classes not thread-safe. should not place mutable fields on class, instead using form bean class form fields passed action.
- struts 2 action classes thread-safe. new copies instantiated each request , placing instance fields on class core concept in framework.
* if instance or static field immutable, fine multiple threads access simultaneously.
Comments
Post a Comment