This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Struts and Thread safe

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, guys!

I was thinking about thread safety and..
I know that when you're working with Servlets and JSP's (without a framework) you have to take care of thread safety yourself.
For instance, if I have an application scoped attribute I know I have to synchronize that attribute to avoid multiple access on it.
But the question is...
Does Struts take care of it, or do I have to do the same work with my variables or attributes in the framework?

I'm asking this becouse I'm working on a big system that uses Struts as the framework and I never saw any synchronized code protecting these attributes in the entire application.
I think it's wrong...

Can anyone help me!?

Thank's!

-> Sorry for the English. I'm still learning... :-)
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alexandre.

Struts does not automatically protect you against thread-safety issues. As you said it yourself, if you have an object in your application that is somehow shared by different threads, you might need to synchronize access to it. Regarding Struts (or other frameworks) you should be aware of how they work and their micro-architecture so you don't insert flaws into your design. For instance, it is not a good idea to put data members in Struts action classes (there's no guarantee about their thread-safety because Struts might use the same action instance for distinct requests).
 
Alexandre Baldo
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Valeu, Leandro!
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!