title: java access class's variable in thread and use outside thread
body: <p>I've a GUI Class Named as <code>NewFrame.java</code> and another one is <code>Client.java</code>. in Client.java, the NewFrame's object is made inside a thread. ex,</p>
  
  <pre><code>public class ClientA {
  
  NewJFrame gui;
  int x ;
  
  public void go() {
              java.awt.EventQueue.invokeLater(new Runnable() {
              @Override
              public void run() {
                  gui  = new NewJFrame();
                  gui.setVisible(true);
                  x = 10;
              }
          });
  
          System.out.println(x); // does not print 10 but it prints 0
  
          gui.setTextboxvalue("value changed !!!"); 
  
          // can'se pass value to the function, with this error occurs as,
          // "java.lang.NullPointerException" at here.
  
        }
  }
  </code></pre>
  
  <p>here two problems occuring,
  there is the setter method in NewFrame class named <code>setTextboxValue</code> but calling this as shown above the error occurs "java.lang.NullPointerException".</p>
  
  <p>another problem is : why i can't set the variable <code>x</code> inside that thread, setting this inside thread, the outside printing the variable <code>x</code>'s value which is 10 is not printing there instead it prints <code>0</code></p>