Multi threading by extending Thread class

package threaddemo;
class Thread1 extends Thread{
	public void run(){
		System.out.println(Thread.currentThread().getName());
	}
}
class Thread2 extends Thread{
	public void run(){
		System.out.println(Thread.currentThread().getName());
	}
}
public class ThreadDemo1 extends Thread {
	public void run()
	{
		System.out.println(Thread.currentThread().getName());
	}
	public static void main(String[] args) 
	{
		ThreadDemo1 th1=new ThreadDemo1();
		th1.setName("Thread1");
		th1.start();
		Thread1 th2=new Thread1();
		th2.start();
		Thread2 th3=new Thread2();
		th3.start();
	}
}

Download

Thread Source Code

Thread by extending Thread class
Thread by implementing Runnable interface
Multithread by implementing Runnable interface
Thread Intercommunication
Thread Join Example
Thread Join Example
Main Thread information
Multithreaded Example
Thread Priority
Thread Priority
Thread yield example


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code