title: How do i reference a method from a different threads java
body: <p>I'm trying to reference thread a from thread b, I essentially want to use the getN() method in B class/thread, any help is appreciated  </p>
  
  <pre><code>//// class help {
      ///// main {
  
          Thread a = new Thread(new A());
          Thread b = new Thread(new B(a));
      }
  }
  
  class A implements Runnable {
      private static int tally;
      public void run() {
  
      }
      public int getN() {
          tally = 6;
          return tally;
      }
  }
  
  class B implements Runnable {
      private A aref;
      public B(A ref){
          aref=ref;
      }
      public void run() {
          aref.getN();
      }
  }
  </code></pre>
  
  <p>//////////////////////////////////////////////////////////////////
  /////////////////////////</p>