Snippets tagged “runnable”
5 snippets use this tag.
- "implements Runnable" vs "extends Thread" in JavaJava
In Java, you can create a thread in two ways: by implementing the Runnable interface or by extending the Thread class.
- Functional style of Java 8's Optional.ifPresent and if-not-Present?Java
The ifPresent() and ifPresentOrElse() methods of the Optional class in Java 8 provide a functional style way to perform different actions depending on whether the Optional object is empty or contains a value.
- How can I pass a parameter to a Java Thread?Java
To pass a parameter to a Java thread, you can use a Runnable object and pass the parameter to its constructor.
- How do you kill a Thread in Java?Java
To stop a thread in Java, you can use the interrupt() method of the Thread class.
- How to call a method after a delay in AndroidJava
To call a method after a delay in Android, you can use the Handler class and the postDelayed() method. The postDelayed() method takes a Runnable and a delay in milliseconds as arguments, and it runs the Runnable after the specified delay.