I am generating timing events in a loop in a (non-UI) thread in an Android application, and I need those events to occur at precise intervals in time, (precise here means no
I'm using delayed messages with Handler
for similar purpose. It can be little overkill. In you case I would take a look to Timer
class.
mTimer = new Timer();
mTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
Log.v("TEST", " tick");
}
}, 0, 250);
This gives me latency +-2 millisecs at emulator.