请大侠帮忙解决一个线程问题!小弟感激不尽!
本人刚学java 不久,在验证多线程如何在同一程序中运行时,此程序不知哪里出了问题,请高手帮忙看看!谢谢你们得指点迷津!
class Sister extends Thread{
public Sister(String str){
super(str);
}
public void run(){
for(int i=0;i<6;i++)
{
System.out.println(getName()+"is running:"+i);
try{sleep((int)(Math.random()*1000));}
catch(InterruptedException e){}
}
}
System.out.println(getName()+"is running:"+i);
}
class CountingThread {
public static void main(String []args){
System.out.println("the siters Janny and Marry are counting the threads");
System.out.println("who are the first to runnig?");
new Sister("Janny").start();
new Sister("Marry").start();
}
}