title: Pass data from thread into Activity
body: <p>I am want to pass data back from a <code>Thread</code> to <code>Activity</code> (which created the thread). </p>
  
  <p>So I am doing like described on <a href="http://developer.android.com/guide/appendix/faq/commontasks.html#threading" rel="nofollow noreferrer">Android documentation</a>:</p>
  
  <pre><code>public class MyActivity extends Activity {
  
      [ . . . ]
      // Need handler for callbacks to the UI thread
      final Handler mHandler = new Handler();
  
      // Create runnable for posting
      final Runnable mUpdateResults = new Runnable() {
          public void run() {
              updateResultsInUi();
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          [ . . . ]
      }
  
      protected void startLongRunningOperation() {
  
          // Fire off a thread to do some work that we shouldn't do directly in the UI thread
          Thread t = new Thread() {
              public void run() {
                  mResults = doSomethingExpensive();
                  mHandler.post(mUpdateResults);
              }
          };
          t.start();
      }
  
      private void updateResultsInUi() {
  
          // Back in the UI thread -- update our UI elements based on the data in mResults
          [ . . . ]
      }
  }
  </code></pre>
  
  <p>Only one thing I am missing here - where and how should be defined <code>mResults</code> so I could access it from both <code>Activity</code> and <code>Thread</code>, and also would be able to modify as needed? If I define it as <code>final</code> in <code>MyActivity</code>, I can't change it anymore in <code>Thread</code> - as it is shown in example...</p>
  
  <p>Thanks!</p>