Home Tutorial Java Thread Java Thread class

 
 

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


Advertisement

Related Tags for Java Thread class:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 6, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com