Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets and Threads (URGENT)  RSS feed

 
koray guclu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to implement the following code. But I didnot understand the Thread based problems in Servlets. Should I use Syncronized {} at the following code when changing a variable in the servlet code?

Thanks
I will use this at my open source project at http://project1.sourceforge.net/index.html
Koray
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally speaking you don't have to synchronize (small s) any code in a servlet as long as the variable is local to the method or otherwise uniquely associated with the request. If userHasaSession is local, no problem. You should never use instance variables for something like this.
userHasaSession = true ;
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!