public class Test{
public static void main(String[] args){
Dog dog=new Dog();
dog.start();
}
}
class Dog extends Thread{
int times=0;
public void run(){
while(true)
{
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
times++;
System.out.println("HELLO,WORLD!"+times);
if(times==10) break;
}
}
}
public class Test{
public static void main(String[] args){
Dog dog=new Dog();
Thread t=new Thread(dog);
t.start();
}
}
class Dog implements Runnable{
int times=0;
public void run(){
while(true)
{
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
times++;
System.out.println("HELLO,WORLD!"+times);
if(times==10) break;
}
}
}