Java线程
线程的从创建方式
一:继承Thread类创建线程类
class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } } The following code would then create a thread and start it running: PrimeThread p = new PrimeThread(143); p.start();
二:实现Runnable接口创建线程类
class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPri