Rohit Gupta
What is Runnable interface in Java?
By Rohit Gupta in Java on Sep 10 2019
  • Vijay Kumari
    Sep, 2019 16

    The runnable interface must be implemented by any class, whose instances are intended to be executed by a thread. The Runnable interface has only one run() method.

    public void run()

    This method is used to perform an action for a thread.

    For a detailed tutorial on Java MultiThreading, visit
    https://www.c-sharpcorner.com/article/a-complete-multithreading-tutorial-in-java/

    • 1
  • Laxmidhar Sahoo
    Jan, 2020 1

    Java runnable is an interface used to execute code on a concurrent thread. It is an interface which is implemented by any class if we want that the instances of that class should be executed by a thread.

    public class ExampleClass implements Runnable {

    1. @Override
    2. public void run() {
    3. System.out.println("Thread has ended");
    4. }
    5. public static void main(String[] args) {
    6. ExampleClass ex = new ExampleClass();
    7. Thread t1= new Thread(ex);
    8. t1.start();
    9. System.out.println("Hi");
    10. }

    }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS