Android why does this NOT throw wrong thread exception?

Viewed 277

I was under the impression that views can only be manipulated from the main thread... however, why does this NOT crash:

public class MainActivity extends Activity {
    TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tv = new TextView(this);
        tv.setText("original text");
        setContentView(tv);

        new Thread(new Runnable() {
            @Override
            public void run() {
                tv.setText("trollollolol i should die here but i won't.");
            }
        }).start();        
    }
}

i ran on device & emulator, both work just fine and i see the text change. what's going on?

i also checked thread IDs and the background thread is DEFINITELY not the main thread (threadID = 1)

1 Answers
Related