I would like to know if the value of c3
in ClassOne
and ClassTwo
are considered the same instance of that object. I plan on calling ClassThree
´s check()
method from both classes in seperate threads and want to know if they will interfere with each other.
public class ClassOne{
private ClassThree c3 = new ClassThree();
public ClassOne(){}
public void passThreeToTwo{
ClassTwo.setC3(c3);
}
}
//------------------------------------------------------*
public class ClassTwo{
private static ClassThree c3 = null;
public ClassTwo(){}
public static void setC3(ClassThree c3){
this.c3 = c3;
}
}
//------------------------------------------------------*
public class ClassThree{
public ClassThree(){}
public synchronized check(){}
}
public static void main(String[] args){
ClassOne c1 = new ClassOne();
C1.passThreeToTwo();
}
Hope it's an understandable example and question?