title: Android - howto pass data to the Runnable in runOnUiThread?
body: <p>I need to update some UI and do it inside of the UI thread by using <code>runOnUiThread</code> <br>
  Now the data for the UI comes from the other Thread, represented by <code>data</code> here.<br></p>
  
  <p>How can i pass the data to the Runnable, so tht they can be used to update the UI?
  Android doesn't seem to allow using data directly. Is there an elegant way to do this?</p>
  
  <pre><code>public void OnNewSensorData(Data data) {
  
      runOnUiThread(new Runnable() {
          public void run() {
              //use data
          }
      });
  }
  </code></pre>
  
  <p>My solution was creating a fioeld <code>private Data sensordata</code> inside of the runnable, and assigning data to it. This works only, if the original <code>Data data</code> is final.</p>
  
  <pre><code>public void OnNewSensorData(final Data data) {
  
      runOnUiThread(new Runnable() {
          private Data sensordata = data;
          public void run() {
              //use sensordata which is equal to data
          }
      });
  }
  </code></pre>