河南成教 / Java程序设计
写出下面程序的运行结果。
public class Class34ThreadTest
{
public static void main(String args[])
{
Hello h=new Hello();
Thread t=new Thread(h);
t.start();
}
}
class Hello implements Runnable
{
int i;
public void run()
{
while(true)
{
System.out.println("Hello"+i++);
if(i==5) break;
}
}
}
public class Class34ThreadTest
{
public static void main(String args[])
{
Hello h=new Hello();
Thread t=new Thread(h);
t.start();
}
}
class Hello implements Runnable
{
int i;
public void run()
{
while(true)
{
System.out.println("Hello"+i++);
if(i==5) break;
}
}
}
参考答案: