I want to turn on/off the flash light in infinite loop, so when it turned on it should wait for 5 seconds and then turned off then wait 5 seconds to turned on again, and so on...
how I can do that?

here is my code:

```
b2.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                    //  num = Integer.parseInt(n.getText().toString());

                        while(bl){

                             if(camera == null){

                                 new Thread(new Runnable() {
                                        @Override
                                        public void run() {
                                            try {
                                                Thread.sleep(5000);
                                            } catch (InterruptedException e) {
                                                e.printStackTrace();
                                            }
                                            runOnUiThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    turnOn();
                                                }
                                            });
                                        }
                                    }).start();
                                }

                             else{

                                 new Thread(new Runnable() {
                                        @Override
                                        public void run() {
                                            try {
                                                Thread.sleep(5000);
                                            } catch (InterruptedException e) {
                                                e.printStackTrace();
                                            }
                                            runOnUiThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    turnOff();
                                                }
                                            });
                                        }
                                    }).start();
                                }
                        }

                    }
                });

```