Thread Join

package threaddemo;
class Thread22 extends Thread
{
	public Thread22(){}
	public Thread22(String s)
	{
		super(s);
		System.out.println(this);
		this.start();
	}
	public void run()
	{
		try
		{
		for(int i=0;i<5;i++)
		{
			System.out.println(this);
			this.sleep(1000);
		}
		}
		catch(Exception e){}
	}
}
public class JoinDemo 
{
	public static void main(String[] args) 
	{
		Thread22 th1=new Thread22("One");
		Thread22 th2=new Thread22("Two");
		Thread22 th3=new Thread22("Three");
		System.out.println("It is in main thread");
		try
		{
			th1.join();
			th2.join();
			th3.join();
		}
		catch(Exception e){}	
	}
}

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