title: Android: how to blink LED/flashlight rapidly
body: <p>I am trying to show some effects with the LED/flashlight, but it is not blinking rapidly. I even tried <code>sleep(2)</code>, but it takes time to blink. I want it to blink faster.</p>
  <pre><code>public void flash_effect() throws InterruptedException
  {
      cam = Camera.open();     
      final Parameters p = cam.getParameters();
      p.setFlashMode(Parameters.FLASH_MODE_TORCH);
          
      
      Thread a = new Thread()
      {
          public void run()
          {
              for(int i =0; i &lt; 10; i++)
              {
                  cam.setParameters(p);
                  cam.startPreview();
                  try {
                      Thread.sleep(50);
                  } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  cam.stopPreview();
                  try {
                      Thread.sleep(50);
                  } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                   
              }
          }
      };
      a.start();
  }
  </code></pre>