It's my first time using a thread and I would like to implement it in such a way that it calls a method every x seconds:
new Thread(new Runnable() {
public void run() {
try {
metodoallamar();
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
The best thing is to use a Timer as mentioned by David Luque, but you can also try to leave a cycle inside the thread and use sleep for the pause in this case while it is executing, that is, the boolean execute in true enters the while executes the method waits 10 seconds and repeat the process.
You can use a Handler for this purpose, as an example call a method every 10 seconds (10000 milliseconds):