日期:2014-05-20 浏览次数:20853 次
public class Test3 extends Thread
{
public void run()
{
loop();
}
public void loop()
{
String name = Thread.currentThread().getName();
System.out.println(name+"--->>刚进入loop方法");
for(int i=0;i<10;i++)
{
try
{
Thread.sleep(4000);
}
catch(InterruptedException X)
{
}
System.out.println("name="+name);
}
System.out.println(name+"离开");
}
public static void main(String[] args)
{
Test3 tt=new Test3();
tt.setName("my");
tt.start();
try
{
Thread.sleep(700);
}
catch(InterruptedException x)
{
}
tt.loop();
}
}