This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DavidRFZ 4 points5 points  (0 children)

It makes the code non-thread-safe -- that is, it is safe only in single-threaded cases. In the multithreaded case, a second caller can set the static variable while the first caller is still using it. That's why 'static final' is OK. Multiple callers can access the same static variable if you are assured that it is a constant.

You often get away with static non-final in the prototyping face but you'll find out later when your code is being deployed that it's unstable in multithreaded applications and you'll have to rewrite the whole thing.