www.pudn.com > Thread01.rar > Test.java
import java.lang.Thread; /** *Title:
*Description:
*Copyright: Copyright (c) 2004
*Company:
* @author not attributable * @version 1.0 */ public class Test { public static void main(String args[]){ ThreadA threadA=new ThreadA(); threadA.start(); try{ Thread.sleep(3000); }catch(InterruptedException e){} threadA.interrupt(); try{ threadA.join(); }catch(InterruptedException e){} } } class ThreadA extends Thread{ public void run(){ int flag=0; try{ while(flag<10){ System.out.println("flag = "+flag); flag++; Thread.sleep(1000); } }catch(InterruptedException e){System.out.println("Thread A interrupted!");} } }