package come.hanqi; public class zuoye extends Thread { public void run(){ zy(); } public void zy(){ for(int i=0;i<20;i++){ System.out.println("张昊哲好帅!"); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }
package come.hanqi; public class TestThread { public static void main(String[] args) throws InterruptedException { zuoye zuo=new zuoye(); zuo.zy(); } }