Skip to content

Instantly share code, notes, and snippets.

@ajduke
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajduke/9889914 to your computer and use it in GitHub Desktop.
Save ajduke/9889914 to your computer and use it in GitHub Desktop.
desc
public class Task1 {
public static void main(String[] args) {
// run in a second
final long timeInterval = 1000;
Runnable runnable = new Runnable() {
public void run() {
while (true) {
// ------- code for task to run
System.out.println("Hello !!");
// ------- ends here
try {
Thread.sleep(timeInterval);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
Thread thread = new Thread(runnable);
thread.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment