Home Tutorial Java Thread Java Thread class

 
 

Java Thread class
Posted on: November 6, 2009 at 12:00 AM
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.

  • Java Thread Class is a piece of the program execution
  • Java has multithreading facility.
  • It allows multiple works(threads) to run at a time
  • It is created by extending the Thread class or implementing Runnable interface


Java Thread Class Example
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


Related Tags for Java Thread class: