Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Thread Safety in Action Servlets

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Struts People,
Any specific pointers on how to make access to the HTTPSession, specifically properties in the session, thread-safe? Should synchronization be used whenever accessing session properties? Is it enough to limit access to session variables just from within the Action Servlet's perform method?
-j
 
author
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP Session variables are your own. They just belong to you no one else.
The question of thread safety doesnt arise
 
Jason Stull
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srikanth for your reply. I've heard good things about your Struts book. I guess I'm refering to the Struts API docs for the Action class:
Action
Where it states, "Access to other resources (JavaBeans, session variables, etc.) MUST be synchronized if those resources require protection. (Generally, however, resource classes should be designed to provide their own protection where necessary."
Does this just refer to resources used by more than one session, Singletons, etc?
 
Srikanth Shenoy
author
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
I had never looked at it before. But it definitely sounds vague.
I am not exactly sure what they were trying to convey.
I would take a guess: They are probably referring to shared resources, and, as you said, singleton loosely belongs to shared resource category.
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic