java - synchronizing global variables in a servlet -
i have couple of global variables in servlet. individual servlet sessions read , wrote these variables. used coordinate values posted database important sessions remain in synch. question can use synchronize key words servlets keep different servlet sessions colliding each other @ these global variables?
thank you,
i'd recommend not doing stuff in servlet class itself. have servlet's doget() etc. call object real work. if delegated class singleton have full control on initialization, state etc.
if rely on how app server loads servlet class things can brittle. best let server classload/share servlet whenever feels , not depend on specific behavior.
Comments
Post a Comment