Random inside a thread won't work
<p>I'm trying to run a Random method inside a Thread. I need to put this inside a thread because it kept hanging up my main UI Thread. But seems it's not working. Log returns 0 size. I need help, code below.</p>

<pre><code>public class RandomActivity extends Activity implements Runnable {
private TextView random;
Thread thread;
private boolean flagRandom;
private ArrayList&lt;Integer&gt; listRandom;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    thread = new Thread(this);
    flagRandom = false;
    listRandom = new ArrayList&lt;Integer&gt;();
    random = (TextView) findViewById(R.id.txtRandom);
    thread.start();
    for(int i=0; i&lt;5; i++) {
        Log.i("RANDOM", listRandom.get(i).toString());
    }
}
@Override
public void run() {
    Random rNum = new Random();
    while(flagRandom) {
        for(int ctr=0; ctr&lt;5; ctr++) {
            if(ctr &gt; 0) {
                int iRand = rNum.nextInt(5) + 1;
                if(listRandom.contains(iRand)) {
                    ctr--;
                } else {
                    listRandom.add(iRand);
                }
            } else {
                listRandom.add(rNum.nextInt(5) + 1);
            }
        }
    }
}
</code></pre>

<p>}</p>
