Share on Google+Share on Google+

Java MultiThread

In this segment of tutorial we will learn about the MultiThread in the java and how it is used.Then We will create an example for the Multi thread and print the output.

  • Java has multithreading feature.
  • Multithreading feature is given by Thread class and Runnable interface
  • Java Multithreading allows to run multiple tasks(threads) at a time.

Java Multi Thread Example
public class multi extends Thread {
	public void run() {
		for (int x = 1; x <= 3; x++) {
			System.out.println(x + " Thread name"
					+ Thread.currentThread().getName());

	public static void main(String[] args) {
		multi t1 = new multi();

		multi t2 = new multi();

		multi t3 = new multi();


1 Thread nameThread-1 2 Thread nameThread-1 1 Thread nameThread-0 2 Thread nameThread-0 3 Thread nameThread-0 1 Thread nameThread-2 2 Thread nameThread-2 3 Thread nameThread-2 3 Thread nameThread-1


Posted on: November 7, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.


Advertisement null