-
-
Save parzibyte/13b84e06773bb2c9d2820c7df59ea3f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Runnable runnable = new Runnable() { | |
@Override | |
public void run() { | |
// Esto se ejecuta en segundo plano una única vez | |
while (true) { | |
// Pero usamos un truco y hacemos un ciclo infinito | |
try { | |
// En él, hacemos que el hilo duerma | |
Thread.sleep(1000); | |
// Y después realizamos las operaciones | |
System.out.println("Me imprimo cada segundo"); | |
// Así, se da la impresión de que se ejecuta cada cierto tiempo | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment