title: Blocking the main thread
body: <p>I am not understanding why my main UI thread is getting blocked. I have button which calls function doSomething(). </p>
  
  <pre><code>    randomButton.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      doSomething();    
                  }
      });
  }
  
      // My private helper funtion
  
      private void doSomething() {
  
                  Thread t1 = new Thread() {
  
                      @Override
                      public void run() {
  
                          long startTime = SystemClock.uptimeMillis();
                          Log.e(TAG, "Start Time = "+startTime);
                          while((SystemClock.uptimeMillis()-startTime)&lt;6000){// Loop for 6 seconds
                              Log.e(TAG, "Diff ="+(SystemClock.uptimeMillis()-startTime));                        
                          }    
                      }    
                  };
                  t1.run();
          }
  </code></pre>
  
  <p>The problem is when I press the button, it remains pressed for how much ever time my loop run (here 6 secs). I want it in a such a way that user can still use his UI elements even though the loop keeps running. Thats the reason I created a new Thread. Am I doing something wrong ?</p>
  
  <p>Thanks</p>