线程的俩类实现方式

线程的俩种实现方式(1)package com.yan.testpublic class TestRunnable implements Runnable {public voi

线程的俩种实现方式

(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();}}

?