title: Time Delay In Android
body: <p>So I am trying to create a "strobe" light effect in my app.</p>
  
  <p>To do this I need a time delay, one of 100ms the other of 20.</p>
  
  <p>Here is the code I'm using.</p>
  
  <pre><code>Thread timer = new Thread();
      long longTime = 100;
      long shortTime = 20;
      for (int x = 0; x &lt; 2000000; x++)
      {
          layout.setBackgroundColor(background);
          try {
              timer.sleep(longTime);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          layout.setBackgroundColor(backgroundBlack);
          try {
              timer.sleep(shortTime);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>The issue I have is that when I click the button to call that code, nothing happens. So I've done a bit of debugging and am pretty sure it is the timing call. I have never programmed in Java before so I am unsure how to call a Thread Sleep.</p>