线程的俩种实现方式
(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();}}?