I have a `Button` in my `Activity` which, if not clicked within 5 seconds from creating the `Activity`, I want to crash the App. I tried the following but found out from logging that the `OnClickListener` code is executed after all other code in `onCreate(Bundle)` is run. So the boolean is always `false` when it is checked. How can I fix this?

```
private Boolean isClicked = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.e("0-isClicked", String.valueOf(isClicked));
    setContentView(R.layout.activity_main_map);

    ImageView iv = (ImageView) findViewById(R.id.myBTN);
    iv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), MainActivity.class);
            isClicked = true;
            Log.e("1-isClicked", String.valueOf(isClicked));
            startActivity(i);
        }
    });
    Log.e("2-isClicked", String.valueOf(isClicked));

    //let app crashes after 5 seconds (5000 milliseconds) if user didn't take action
    if (!isClicked) {
        Log.e("3-isClicked", String.valueOf(isClicked));
        Thread timer = new Thread() {
            public void run() {
                try {
                    sleep(5000);
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    throw null;
                }
            }
        };
        timer.start();
    }   
}

```

And this is what LogCat gives:

```
E/0-isClicked﹕ false
E/2-isClicked﹕ false
E/3-isClicked﹕ false
E/1-isClicked﹕ true

```