Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

threading  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel the best way to ensure ur aplcn is threead safe is have all the parameters in session objects.
am i correct???
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The best way to ensure thread-safety is to enclose critical code inside synchronized blocks. A parameter cannot be set inside a session.
-anthony
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a little over-simplified.
1. You only need to keep in a session those bits of data you will need on the next request from that user. Otherwise, local variables will be fine. No need to fill up session memory needlessly. Just never use instance variables for user-specific data.
2. Synchronization is only needed when the object in question may be seen by more than one request Thread - in other words, an instance variable or system resource. Synchronizing on a local variable does nothing, since only one Thread can ever see that variable. You may have to synchronize on a variable stored in a session if there is a chance the same user may have more than one request pending at one time - as in pages with frames or multiple resources such as images.
Bill
(incidently, why are you using that abominable shorthand " ur aplcn " - yuch)
[ March 23, 2002: Message edited by: William Brogden ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!