In this segment of tutorial we will learn about the Runnable Interface and its use.Then We will create an example for the Runnable Interface and print the content.
In this segment of tutorial we will learn about the Runnable Interface and its use.Then We will create an example for the Runnable Interface and print the content.
public class runnable1 implements Runnable { @Override public void run() { for (int x = 1; x <= 3; x++) { System.out.println(x + " Thread name, priority and group are " + Thread.currentThread()); } } public static void main(String[] args) { runnable1 run1 = new runnable1(); Thread t1 = new Thread(run1); t1.start(); } }Output 1 Thread name, priority and group are Thread[Thread-0,5,main] 2 Thread name, priority and group are Thread[Thread-0,5,main] 3 Thread name, priority and group are Thread[Thread-0,5,main]