We can define a Thread by implementing Runnable interface.
public class RunnableClass implements Runnable{
@Override
public void run() {
System.out.println("Runnable interface");
}
}
class RunnableExample{
public static void main(String[] args) {
RunnableClass object = new RunnableClass();
Thread t = new Thread(object);
t.start();
}}
Similar Java Tutorials
- Odd Even in Java
- Method to print exception information in Java
- Exception Handling by Using try-catch in Java
- Checked Exception vs Unchecked Exception
- Exception Hierarchy in Java
- Java Exception Handling Interview Questions
- final finally finalize in java
- User Defined Exception in Java
- Exception Handling Keyword in Java
- throw throws in Java
- try with multiple catch block in Java
- Threads in Java