I have:
public class UTIL{
public static void met(){
do_something(){
print(A.m());
}
}
}
public class A{
public <type> m;
public <type>static m(){
return m;
}
}
Now:
Thread A contains instance of class A
Thread B contains instance of class A
From Thread B, at some point UTIL.met is called.
Question:
When UTIL.met is called, will it use m from the instance of A in Thread B?
No, it doesn’t matter if Thread A has one instance and Thread B has another.
A.mis static and common for all instances.But it is definitely the case that if the variables are static, then both threads will use the same variable.
(In other words, without proper synchronization, you’ll have nasty race-conditions.)