Creating Thread by extending Thread class

class App extends Thread{
	public App(){}
	public App(String s)	{
		super(s);
	}
public void run()
{
	for(int i=1;i>0;i++)
	System.out.println(Thread.currentThread().getName());
}
}
public class App1 
{
	public static void main(String[] args) throws Exception
	{
	App a=new App("Thread One");
	a.setPriority(10);
	a.start();
	App b=new App("Thread Two");
	b.setPriority(1);
	b.start();
	// a.run();
	System.out.println("I am in main method");
	System.out.println("I am waiting for Thread One");
for(;;)
	System.out.println("in main");
	}
}

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