I have some static variables in a class. When the http request comes in it sets some values of the static variables and based on these static variables a list is created using values from the database. Each request comes in with different values. I guess when each request comes in it runs in a different thread. Is the values static variables used by each thread different, or the value set by the second request is used by the first thread as well? I appreciate your help. Thank you very much in advance.
Is the values static variables used by each thread different
static variables are shared between all *objects* may or may not be in different threads. If there are two different instances of the same class in two different thread and you assume the value of a static variable to be constant in one thread execution, it is a recipie for disaster In this case you would have to *protect* the access of the static variables by locks. [ May 09, 2007: Message edited by: Nitesh Kant ]
Using the session is indeed often a good thing in Web apps. Whether it is correct in your situation depends whether the thing you're storing really is one-per-session or one-per-thread. If it's the latter, then using the session is not really correct, and could go wrong.
There is a class ThreadLocal that can be used to get independent values of a variable for each thread. Check it out in the API.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.