// 继承 Thread 类 classPrimeThreadextendsThread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } publicvoidrun() { // compute primes larger than minPrime . . . } } // The following code would then create a thread and start it running: PrimeThreadp=newPrimeThread(143); p.start(); // 实现 Runnable 接口 classPrimeRunimplementsRunnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } publicvoidrun() { // compute primes larger than minPrime . . . } } // The following code would then create a thread and start it running: PrimeRunp=newPrimeRun(143); newThread(p).start();