title: Android Studio: Changing visibility of layout element, wrong order of execution
body: <p>We're trying to show a loading screen, do some expensive operations (represented with the sleep) and after the operation finished display a message.</p>
  
  <p>expected behaviour: 
  STEP 1: the visibility of rl_loading (RelativeLayout) is set to visible
  STEP 2: application sleeps for 2 seconds
  STEP 3: message is shown</p>
  
  <p>what actually happens:
  STEP 2: the application sleeps for 2 seconds
  STEP 1+3: visibility changes and message is shown at the same time</p>
  
  <p>Could anyone please explain why that happens and what to change to achieve the expected behaviour?</p>
  
  <pre><code> mainIcon.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  rl_loading.setVisibility(View.VISIBLE); //STEP 1
                  try { 
                      Thread.sleep(2000); //STEP 2
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
                  msg("message"); //STEP 3
              }
          });
  </code></pre>