title: Best way to share updated data between classes in java
body: <p>I am working on a projects and I have run into a problem, I don't know the best way to share updated data between classes. The current way that I am doing this is by having a static instance of my class in it and having all the other classes change the instance and not the original class.</p>
  
  <pre><code>public class A{
    public static volatile instance;
    public B b = new B();
    public C c = new C();
    public D d = new D();
    public A(){
    this.instance = this;
    b.changeData();
    }
  }
  
  public class B{
    public void changeData(){
    A.instance.d.changeSomethingInD();
    }
  }
  </code></pre>
  
  <p>Now, all the changes that D made to its variables can be accessed by B and C. Is there a better way to do this?</p>
  
  <p>Edit 1: The problem that I have is having updated variables accessible to all the other classes. This was what I was doing before: </p>
  
  <pre><code>public class MainClass extends JavaPlugin{
    private RegionLoader rLoader;
    private ClassesLoader cLoader;
    private MessageHandler mHandler;
    private PlayerDates pDates;
  
    public MainClass(){
  
        dirMaker();
  
        mHandler = new MessageHandler(this);
        pDates = new PlayerDates(this);
        cLoader = new ClassesLoader(this);
        rLoader = new RegionLoader(this);
  
    }
  //getters and setters
  }
  </code></pre>
  
  <p>But the problem is if the RegionLoader changes somithing within itself, the ClassesLoader won't have the updated variables and will work with the old ones, or would it?</p>