class A implements Runnable
{
public void run()
{
for(int i=0; i<10; i++)
{
try
{
Thread.sleep(1000);
}
catch (Exception e)
{
System.out.println(e);
}
System.out.println(Thread.currentThread().getName() + "is running");
}
}
}
public class Object9
{
public static void main(String args[])throws Exception
{
Thread p = new Thread(new A(),"1~~~");
p.start(); p.sleep(10000);//问题:如果此处用 Thread.sleep(10000)
//结果是一样的,为什么? 两者有什么区别 for(int i=0; i<10; i++)
System.out.println("@@@@@@@@");
}
}
{
public void run()
{
for(int i=0; i<10; i++)
{
try
{
Thread.sleep(1000);
}
catch (Exception e)
{
System.out.println(e);
}
System.out.println(Thread.currentThread().getName() + "is running");
}
}
}
public class Object9
{
public static void main(String args[])throws Exception
{
Thread p = new Thread(new A(),"1~~~");
p.start(); p.sleep(10000);//问题:如果此处用 Thread.sleep(10000)
//结果是一样的,为什么? 两者有什么区别 for(int i=0; i<10; i++)
System.out.println("@@@@@@@@");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货