直播商城源码,android线程的介绍及两种启动方式
直播商城源码,android线程的介绍及两种启动方式
一种是直接继承Thread类:(代码直接是复制Thread类中官方给的),调用Thread自己的run方法
* 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();
public
class Thread implements Runnable {
// Android-removed: registerNatives() not used on Android.
/*
/* Make sure registerNatives is the first thing <clinit> does. *
private static native void registerNatives();
static {
registerNatives();
}
*/
第二种是实现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();
以上就是 直播商城源码,android线程的介绍及两种启动方式,更多内容欢迎关注之后的文章