//继承thread类 class PrimeThread extends Thread{ long minPrime; PrimeThread(long minPrime) { this.minPrime=minPrime; } public void run(){ //computer primes larger than minPrime } } //调用方法 PrimeThread p=new PrimeThread(143); p.start(); //调用Runnable接口 class PrimeRun implements Runnable{ long minPrime; PrimeRun(long minPrime){ this.minPrime=minPrime; } public void run(){ //compuyer primes larger than minPrime } } //调用方法 PrimeRun p=new PrimeRun(143); new Thread(p).start();
时间: 2024-10-02 21:44:42