Fixing of bug for a small program
Hallo I fount this code but I think is not right. Could you repair this code. What is missing?
Code :
class Save {
private int value;
public sychronized void setValue(int i) {
this.value = i;
}
public sychronized Object getValue() {
return this.value;
}
}
class ThreadOne {
private Save save;
run() {
...
save.setValue(x);
}
}
class ThreadTwo {
private Save save;
run() {
...
Sysout(save.getValue())
}
}
Save save = new Save();
ThreadOne one = new ThreadOne();
one.setSave(save);
ThreadTwo two = new ThreadTwo();
two.setSave(save);
one.start();
two.start();
Thank you