Concurrent Access does not modify an attribute
Good day,
I'm working on a multi-process environment, whose main class could be summed up as this:
public Class ServerCluster{
// In reality, this attribute belongs to a superior class and is protected
private SolverCluster solverCluster;
//...
publicvoid installSolver (SolverCluster newSolverCluster){
// Tests here to check the newSolverCluster isn't null
//...
sychronized (this){
System.out.println("A new SolverCluster is given");
this.SolverCluster = newSolverCluster;
}
}
publicvoid mainProcess(){
//...
while (true){
synchronized (this){
if (this.solverCluster !=null){
System.out.println("the solverCluster isn't null");
//That's where we want to go
//...
}
//...
}
thread.sleep(1000);
}
}
}
Basically, a process started from another class calls the method mainProcess and then stays inside.
Then, another Java process connects to the serverCluster (by RMI) and calls the method installSolver.
The problem is that the message "A solverCluster is given" is displayed, but when the process leaves the method, the attribute becomes null again and therefore the message "the solverCluster isn't null" in the mainProcess method is never displayed.
(I'm using NetBeans 4.1.).
Thank you

