javatutelearn.com
Easy Learning
Search Javatutelearn.com :
public class stopexmp extends Thread { public void run(){ for(int i=0;i<5;i++){ System.out.println("current thread is "+ Thread.currentThread().getName()); } } public static void main(String args[]) { stopexmp t1 = new stopexmp(); stopexmp t2 = new stopexmp(); t1.start(); t2.start(); for(int i=0;i<5;i++){ System.out.println( "current thread is "+ Thread.currentThread().getName()); } t2.stop(); } }
current thread is Thread-0 current thread is Thread-0 current thread is main current thread is Thread-1 current thread is main current thread is main current thread is Thread-0 current thread is Thread-0 current thread is main current thread is Thread-1 current thread is main current thread is Thread-0