(1)
package com.yan.test;
public class TestRunnable implements Runnable {
public void run() {
for (int i = 0; i < 5; i++) {
System.out.println(Thread.currentThread().getName() + "(- -)" + i);
}
}
public static void main(String args[]) throws InterruptedException {
Thread t = new Thread(new TestRunnable());
t.start();
}
}
(2)
package com.yan.test;
public class TestThread extends Thread {
public void run() {
for (int i = 0; i < 5; i++) {
System.out.println(Thread.currentThread().getName() + "(- -)" + i);
}
}
public static void main(String args[]) {
TestThread t = new TestThread();
t.start();
}
}

被折叠的 条评论
为什么被折叠?



