As explained here, various type of lock can be used. If you want to be always on, then you can acquire it outside the loop :
boolean end = false;
wakeLock.acquire();
while(!end){
//Do stuff
Thread.sleep(10000);
}
wakeLock.release();
But you shouldn't really use a loop for that, try an handler instead to do repeating tasks : http://developer.android.com/reference/android/os/Handler.html
Example :
private class MyRunnable implements Runnable {
@Override
public void run() {
// Do stuff
handler.postDelayed(new MyRunnable(), 100000);
}
}
Handler handler = new android.os.Handler();
handler.postDelayed(new MyRunnable(), 1000000);
The handler is useful if you need to do a repeating task often and with a short period. If there period is longer (like few hours), use the AlarmManager : Alarm Manager Example That is a good example of what you can do, and they also use a wakelock for their tasks.