I wrote program that changes member variable of some object with thread, but when I want to print that variable, it prints old value. I have tried debugging, it works correctly. Any suggestions, i do not understand what is wrong.
public class Auction {
private volatile int currentBid;
public Auction(int currentBid){
this.currentBid=currentBid;
}
public int getCurrentBid(){
return this.currentBid;
}
public synchronized void changeBid(int value){
this.currentBid+=value;
}
Public class User {
private String name,
private int age,
public User(String name,int age){
this.name=name;
this.age=age;
}
public void changeBid(Auction auction, int changeValue){
Thread thread=new Thread(new Bid(auction,changeValue));
thread.start();
}