Win a copy of Emmy in the Key of Code this week in the General Computing 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
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Beans in Spring

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there!

Are beans created by the Spring container can be considered thread safe
when instantiated in a Struts action?

arnel
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether the beans are thread-safe or not depends on how the beans have been implemented. Having said that, singleton beans are more likely to be non-thread-safe while prototype (non-singleton) beans are more likely to be thread-safe. Still, it's up to what your code does inside the methods that counts.
 
arnel nicolas
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. So the bottom line is bean declared singleton cannot be considered thread-safe.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by arnel nicolas:
Thanks for the reply. So the bottom line is bean declared singleton cannot be considered thread-safe.


Not by definition, no. A singleton bean can be thread-safe, but there's no way of knowing that without looking at the code.
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a longer discussion of Singletons and Threadsafety.
http://c2.com/cgi/wiki?JavaSingleton
But as said before its no spring issue.
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!