public class TestThread {
public TestThread()
{
System.out.println(Thread.currentThread().getName() + " Thread start running...");
new LewisSay("A").start();
new LewisSay("B").start();
System.out.println(Thread.currentThread().getName() + " Thread running stop...");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new TestThread();
}
public class LewisSay extends Thread
{
public LewisSay(String ThreadName)
{
super(ThreadName);
}
public void run()
{
System.out.println(getName() +" Thread start running...");
for(int i = 0 ; i < 10 ; i++)
{
System.out.println(i + " " + getName());
try
{
sleep((int)Math.random()*10);
}
catch(InterruptedException e)
{}
}
System.out.println(getName() +" Thread running stop...");
}
}
}