/**
* aThread.java
* @author cjc
*/
public class aThread extends Thread
{
public void run()
{
for(int i=0;i<10;i++)
{
System.out.println("The son thread1 is running...");
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}/**
* bThread.java
* @author cjc
*/
public class bThread implements Runnable
{
public void run()
{
for(int i=0;i<10;i++)
{
System.out.println("The son thread2 is running...");
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}/**
* ThreadDemo1.java
* @author cjc
*/
public class ThreadDemo1
{
public static void main(String[] args)
{
new aThread().start();
Thread th=new Thread(new bThread());
th.start();
for(int i=0;i<10;i++)
{
System.out.println("The main thread is running...");
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
原文地址:http://blog.csdn.net/cjc211322/article/details/24999163