title: Difference between android runOnUiThread and simple code in java
body: <p>I am a beginner in android application development.I am working with threads in android.I have read about a <code>runOnUiThread</code> which run code on main UI(if i am not wrong?i guess.).</p>
  
  <p>My question is what is the difference between normal code on main UI and code inside <code>runOnIUThread</code>.</p>
  
  <p><strong>Example:1</strong></p>
  
  <pre><code>class A
  {
  getDataFromServer(foo);//Code on mainUI
  }
  </code></pre>
  
  <p><strong>Example:2</strong>    </p>
  
  <pre><code>getActivity.runOnUiThread(new Runnable(){
  @Override
  public void run(){
  getDataFromServer(foo);
  }
  });
  </code></pre>
  
  <p>What is difference in both example.Please help me.Your response will be a new learning for me.</p>