标签:min thread runable extends div 方式 span run extend
1.继承Thread类
class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
然后启动如下
PrimeThread p = new PrimeThread(143); p.start();
2.实现Runable方法
class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
然后启动稍微有一些不同
PrimeRun p = new PrimeRun(143); new Thread(p).start();
标签:min thread runable extends div 方式 span run extend
原文地址:https://www.cnblogs.com/nihaoya-czw/p/10352283.html