title: Variable is null when called from another thread
body: <p>Please explain to me the strange behavior of the variable.
  From the main thread creates an instance of the class "B".
  From the constructor of the parent "A" is called an abstract function "init" of the class "B".
  It initializes a <strong>debugPaint</strong> member of the class "B".</p>
  
  <p>Then, it creates a Thread which periodically calls the function <strong>postDraw</strong>.
  The problem is that if I assign <strong>private volatile Paint debugPaint=null</strong> function <strong>postDraw</strong> receive <strong>debugPaint</strong> member as <strong>null</strong>. Although as I can see in the debugger initialization was successful previously.
  If the assignment to null is not done, then everything works.
  <strong>private volatile Paint debugPaint</strong>;
  What is the problem?</p>
  
  <p>p.s Time between init and postDraw is a lot for a few seconds.</p>
  
  <pre><code>public class A{
  
    public A()
    {
      init();
    }
  
    public void draw(Canvas canvas)
    {
      //some code....
     postDraw(canvas);
    }
  
    abstract public void postDraw(Canvas canvas);
    abstract public void init();
  }
  
  
  public class B extends A{
  
      private volatile Paint  debugPaint=null;//=null problem! not =null ok!
  
      @Override
      public void init()
      {
          debugPaint=new Paint();
      }
  
  
      @Override
      public void postDraw(Canvas canvas)
      {
         canvas.drawRect(0,0,128,128,debugPaint);
      }
  }
  </code></pre>