JAVA快来人啊

来源:百度知道 编辑:UC知道 时间:2024/05/12 01:55:42
JAVA用直接方式创建LeftHand线程类,在此线程体中用for循环来实现输出5个“A”字母,每输出一个“A”字母,线程睡眠500ms。
怎么写出

public class FiveA extends Thread {
public static void main(String[] args) {
new FiveA().start();
}
public void run() {
try {
for (int i = 0; i < 5; i++) {
System.out.println("A");
Thread.sleep(500);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

LeftHand该类继承线程类,在RUN方法中写你的循环,然后直接调用线程睡眠

就在这个类里面写循环
输出个A之后写
Thread.sleep(500);
就可以了