• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Safety

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following spec is clear for me.

SRV.2.3.3.3 Thread Safety
Implementations of the request and response objects are not guaranteed to be thread safe. This means that they should only be used within the scope of the request handling thread. References to the request and response objects must not be given to objects executing in other threads as the resulting behavior may be nondeterministic.



My question is does a scenario arise often in practice? And if so, could you let me know when.

Thanks.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chandana sapparapu:
The following spec is clear for me.


My question is does a scenario arise often in practice? And if so, could you let me know when.

Thanks.




Well, my understanding is that spec describes this point to warn developers not to keep references to the request/response objects in different request handling threads. If you want to try this, then imagine someone saving a reference to the request/response object in the session object, and then trying to access the these objects in different requests handling threads. I am not sure what the behaviour will be as I have not tried this before. But the results will definitely be not as expected.

I guess other javaranchers may explain this in a better way.

Thanks
Tejas
reply
    Bookmark Topic Watch Topic
  • New Topic