class mythread extends Thread {
public void run() {
// TODO Auto-generated method stub
super.run();
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO: handle exception
e.printStackTrace();
}
System.out.println("extends: " + Thread.currentThread().getName());
}
}
}
class mythread1 implements Runnable {
public void run() {
// TODO Auto-generated method stub
while (true) {
try {
Thread.sleep(400);
} catch (InterruptedException e) {
// TODO: handle exception
e.printStackTrace();
}
System.out.println("runnable: " + Thread.currentThread().getName());
}
}
}
文章标题
最新推荐文章于 2024-04-22 16:59:44 发布