title: Android: How to create and pass messages to worker thread from main thread
body: <p>I'm new to multithreading in android and java, I'm having difficult time implementing a simple model in which we can start worker thread and send some message or runnable to the worker thread from main thread where it does some operation and send result to main thread and updating ui thread</p>
  
  <p>I tried this:</p>
  
  <pre><code>public class NewThreadUsingRunnable implements Runnable {
  
  Handler handler;
  
  @Override
  public void run() {
  
      handler = new Handler(){
          @Override
          public void handleMessage(Message msg) {
              Log.i("Message Recieved", " " + msg);
              int result = 2+2
          }
      };
  }
  </code></pre>
  
  <p>MainActivity:</p>
  
  <pre><code>new NewThreadUsingRunnable().run();
  </code></pre>