on 03-16-2006 10:50 AM
Hi, all!
Could anybody tell me how private static variables declared between @@begin others and @@end others are being accessed?
What I mean is: Are they - as class variables - unique within memory and their values therefore not threadsafe or are they unique for each thread?
Thx!
Regards,
Thomas
Thomas,
Theay are just regular java static class fields.
So:
1. public static String KEY = "SOME_VALUE";
-- mutable non-thread safe static class variable
2. final public static String RO_KEY = "SOME_VALUE";
-- immutable (hence thread-safe) static class variable;
3. final public static ThreadLocal THREAD_KEY = new ThreadLocal();
-- static class variable with per-thread content
Valery Silaev
EPAM Systems
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
First of all use of Static variables in WD is not encouraged. As far as possible we should use context only.
Coming to your question the static variables are class variables and these are like normal class static variables of a class and behave like them only.
Thanks and regards
RK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<i>First of all use of Static variables in WD is not encouraged</i>
Yes, if they are used as well-known anti-pattern for sharing data between action / event handler and wdDoModifyView.
More interesting question, that deserves its own place in WD quizes: why using of ThreadLocal in WebDynpro (or any other J2EE container like Web or EJB) could lead to errors / inconsistencies?
Thoughts?
VS
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.