DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem with static variables behaviour

  1. #1
    Join Date
    May 2007

    Question Problem with static variables behaviour

    I have made an application in which i have use static variables so i can use these values from one page to other

    page or on the same page (on the same page bcoz if i use simple variables then on page postback these variables loss

    their data).
    Now I publish this application on local intranet. now suppose if i initialize this varibale say( myStaticVar )to 0 as follow

    myStaticVar =0.

    if there are two users that access this application and one user change its value to 1
    myStaticVar =1
    then the problem occurs that the second user also get the change value.This means the application is not thread safe. how

    this problem can reslove to seperate each user's values to other user's data. as i have declare so many static variables in

    my application.
    Thanks in advance.

  2. #2
    Join Date
    Nov 2003
    Portland, OR
    Typically, you save per-user data in the Session object. You may find this article helpful:
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 2
    Last Post: 02-15-2006, 06:28 PM
  2. Josephus Problem, problem.
    By aesoprock00 in forum Java
    Replies: 2
    Last Post: 01-28-2006, 07:18 PM
  3. static variables...
    By java4life in forum Java
    Replies: 0
    Last Post: 05-13-2003, 03:53 PM
  4. How To Do It - Shared Class Variables Part II
    By Patrick Ireland in forum .NET
    Replies: 3
    Last Post: 04-26-2001, 02:50 AM
  5. private and static
    By Mark in forum Java
    Replies: 3
    Last Post: 06-09-2000, 08:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center