title: how to wake a thread from sleep in android
body: <p>I have an activity thats waiting for the user press on an image. if the user dont press anything in 3 second i want the activity to close (finish()).
  thats my code:</p>
  
  <pre><code>private final int delay = 3000;
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.after_hangup);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
      final ImageView pressToLaunchbrowser = (ImageView) findViewById(R.id.after_hang_up_image);
  
      pressToLaunchbrowser.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              //getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);   // if we want to open the device.
              Intent intent = new Intent(Intent.ACTION_VIEW);
              intent.setData(Uri.parse(url));
              startActivity(intent);
              Thread.interrupted();
          }
      }); 
      new Thread() {
          public void run() {
              try {
                      Thread.sleep(delay);
                      finish();
              }
              catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
      }.start();
  }}
  </code></pre>
  
  <p>My question is how can i wake the Thread if the press was made?  i tried <code>Thread.interrupted();</code> but its not working. the thread still waits 3 seconds if i press or not. Thanks!</p>