java建立多线程的两种方法

/*
        2012年11月4日 23:24:15
        建立线程的第一种方法
*/
class AA extends Thread
{
public void run()
{
while(true)
{
System.out.println("AAAA");
}
}
}
class BB
{
public static void main(String[] args)
{
AA aa1=new AA();
aa1.start();
while(true)
{
System.out.println("BBBBBBBB");
}
}

} 线程

------------------------------------------------------------------------------------------------------------------------------------------------------------------ class

class AA implements Runnable
{
public void run()
{
while(true)
{
System.out.println("AAAA");
}
}

}
class BB
{
public static void main(String[] args)
{
AA aa=new AA();
Thread t=new Thread(aa);
t.start();
while(true)
{
System.out.println("BBBBBBBBBBBBB");
}
}
}
方法

相关文章
相关标签/搜索