• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet variable scope?

 
akshat nimbalkar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i access all the servlet variables in all the service threads? does Synchronization play any role here?
 
Joe Ess
Bartender
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, instance variables would be available. In general this is a Bad Idea since Servlets are multithreaded and accessing instance variables would produce race conditions galore. Synchronizing instance variables to prevent race conditions, on the other hand, reduces the efficiency of multithreading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic