class MyThread implements Runable {
(1) {
while(true){System.out.print("hello");
try { (2) //休眠1秒钟
} catch (InterruptedException e) { e.printStackTrace(); }
}}}
public class Demo{
public static void main(String []s){
MyThread thread1= (3) //声明创建对象thread1
Thread thread = new Thread(thread1,"线程1")
thread.start(); //通过对象thread启动线程
}}