In this segment of tutorial we will learn about the Java Thread Class and how it is used. Then We will create the thread class and print the output.
In this segment of tutorial we will learn about the Java Thread Class and how it is used. Then We will create the thread class and print the output.
public class thread1 extends Thread { @Override public void run() { for (int i = 1; i < 4; i++) { System.out.println("This is thread " + i); } } public static void main(String[] args) { thread1 t1 = new thread1(); t1.start(); } } Output This is thread 1 This is thread 2 This is thread 3