title: Android Run A Function In a Class In New Thread
body: <p>I have this code:</p>
  
  <pre><code>MyClass tmp = new MyClass();
  tmp.setParam1(1);
  tmp.SetParam2("Test");
  tmp.setParam3("Test");
  ...
  </code></pre>
  
  <p>Then I have</p>
  
  <pre><code>tmp.heavyCalc();
  </code></pre>
  
  <p>During this heavy calc operation I have to update progress bar in UI and show user that it's working with update in progress bar and some text to display.
  Now it doesn't work, because I'm not using thread, app becomes stuck and hanged, then suddenly returns that progressbar is 100% and all text all together appears suddenly.</p>
  
  <p>So I decided to make my function to run as new Thread.
  Inside definition of my class, I added <code>implements Runnabl</code>e
  So </p>
  
  <pre><code>public class MyClass implements Runnable{
  </code></pre>
  
  <p>Then I put that <code>heavyCalc()</code> function to be called new <code>Run()</code> function I created:</p>
  
  <pre><code>@Override
  public void Run()
  {
  heavyCalc();
  }
  </code></pre>
  
  <p>Now I do this:</p>
  
  <pre><code>Thread thread = new Thread(tmp);
  tmp.run();
  </code></pre>
  
  <p>It works, but still no change at all in UI, app becomes stuck, then suddenly progressbar 100% and app returns. 
  What I'm missing?</p>