Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what r thread safe variables

 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what r thread safe variables and why in the below options?
if i write multi threaded servlet which of the variables are threadsafe?
1.request variables
2.session varaibles
3.local variables
4.request,session
5.request,session,local
6.session,local
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.request variables - The request object is unique to the Thread executing the service and is not shared by any other threads.

2.session variables - Watch out for possible conflicts if your application generates more than one request "at the same time" - for example if you are using frames or generating images. In that case, the same session is in use in multiple requests.

3.local variables - visible only to the Thread executing the method. However, if you assign a reference to a more visible object to a local variable, it is unsafe.


... I don't understand the intent of 4,5,6
Bill
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
r and i are not threadsafe, are and I maybe.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic