当前位置: 首页 > news >正文

网站上线盈利种子资源

网站上线盈利,种子资源,wordpress用户登录注册插件,本地企业网站建设服务Handler 、 Thread 和 HandlerThread详解 区别: 1)Handler:在Android中负责发送和处理消息,通过它可以实现其他支线线程与主线程之间的消通讯 2)Thread:线程,可以看作是进程的一个实体&#xff…
Handler Thread HandlerThread详解
区别:
1)Handler:在Android中负责发送和处理消息,通过它可以实现其他支线线程与主线程之间的消通讯
2)Thread:线程,可以看作是进程的一个实体,是CPU调度和分派的基本单位,他是比进程更小的独立运行的基本单位
3)HandlerThread:封装了Handler + ThreadHandlerThread适合在有需要一个工作线程(非UI线程)+任务的等待队列的形式,优点是不会有堵塞,
减少了对性能的消耗,缺点是不能同时进行多个任务的处理,需要等待进行处理。处理效率低,可以当成一个轻量级的线程池来用
Handler 实现原理:
由 handler、Looper、MessageQueue 三部分组成,由handler  post( @NonNull Runnable r)消息到到MessageQueue( 单向链表),
而MessageQueue 由Looper 管理做无限的循环取消息队列里面的消息并将消息分给handler处理,
当消息一直循环到MessageQueue里没有消息了,循环就阻塞(相当于结束循环)
然后handler 通过回调方法回调消息给 handleMessage(Message msg) 处理;
部分源码截图:
1.handler 发送消息
2.looper  myLooper 获取一个Thread相对应唯一一个looper,和looper的构造函数(Thread. currentThread() 获取当前代码块被哪个线程调用)
  1. MessageQueue,一个入队方法enqueueMessage() 方法,一个出队方法
详细介绍MessageQueue 参考连接 https://www.sohu.com/a/145311556_675634

HandlerThread 实现  ,本质就是一个线程Thread,(其中封装Looper )

public class HandlerThread extends Thread {
    int mPriority;
    int mTid = -1;
    Looper mLooper;
    public HandlerThread(String name) {
        super(name);
        mPriority = Process.THREAD_PRIORITY_DEFAULT;
    }
    /**
     * Constructs a HandlerThread.
     * @param name
     * @param priority The priority to run the thread at. The value supplied must be from
     * {@link android.os.Process} and not from java.lang.Thread.
     */
    public HandlerThread(String name, int priority) {
        super(name);
        mPriority = priority;
    }
    /**
     * Call back method that can be explicitly overridden if needed to execute some
     * setup before Looper loops.
     */
    protected void onLooperPrepared() {
    }
    @Override
    public void run() {
        mTid = Process.myTid();
        Looper.prepare();
        synchronized (this) {
            mLooper = Looper.myLooper();
            notifyAll();
        }
        Process.setThreadPriority(mPriority);
        onLooperPrepared();
        Looper.loop();
        mTid = -1;
    }
    /**
     * This method returns the Looper associated with this thread. If this thread not been started
     * or for any reason is isAlive() returns false, this method will return null. If this thread
     * has been started, this method will block until the looper has been initialized.  
     * @return The looper.
     */
    public Looper getLooper() {
        if (!isAlive()) {
            return null;
        }
        // If the thread has been started, wait until the looper has been created.
        synchronized (this) {
            while (isAlive() && mLooper == null) {
                try {
                    wait();
                } catch (InterruptedException e) {
                }
            }
        }
        return mLooper;
    }
    public boolean quit() {
        Looper looper = getLooper();
        if (looper != null) {
            looper.quit();
            return true;
        }
        return false;
    }
    public boolean quitSafely() {
        Looper looper = getLooper();
        if (looper != null) {
            looper.quitSafely();
            return true;
        }
        return false;
    }
    /**
     * Returns the identifier of this thread. See Process.myTid().
     */
    public int getThreadId() {
        return mTid;
    }
}

文章转载自:
http://diffract.tgcw.cn
http://transact.tgcw.cn
http://cultch.tgcw.cn
http://agp.tgcw.cn
http://herbless.tgcw.cn
http://roentgenoparent.tgcw.cn
http://alleyway.tgcw.cn
http://foresail.tgcw.cn
http://gallium.tgcw.cn
http://flammule.tgcw.cn
http://hayrake.tgcw.cn
http://tonic.tgcw.cn
http://houseleek.tgcw.cn
http://unlax.tgcw.cn
http://proseman.tgcw.cn
http://rassle.tgcw.cn
http://pterin.tgcw.cn
http://overdesign.tgcw.cn
http://theology.tgcw.cn
http://overtime.tgcw.cn
http://photochemistry.tgcw.cn
http://stylish.tgcw.cn
http://fishbone.tgcw.cn
http://telescopy.tgcw.cn
http://extemporal.tgcw.cn
http://ungoverned.tgcw.cn
http://iatric.tgcw.cn
http://farriery.tgcw.cn
http://struggle.tgcw.cn
http://waterward.tgcw.cn
http://pressroom.tgcw.cn
http://turner.tgcw.cn
http://push.tgcw.cn
http://visitatorial.tgcw.cn
http://comonomer.tgcw.cn
http://paleobiogeography.tgcw.cn
http://insomniac.tgcw.cn
http://shinguard.tgcw.cn
http://triceps.tgcw.cn
http://controllable.tgcw.cn
http://fash.tgcw.cn
http://sousaphone.tgcw.cn
http://hepatotomy.tgcw.cn
http://sephardic.tgcw.cn
http://beast.tgcw.cn
http://superaltern.tgcw.cn
http://plebeianism.tgcw.cn
http://argali.tgcw.cn
http://matriculation.tgcw.cn
http://galliot.tgcw.cn
http://homogenization.tgcw.cn
http://savour.tgcw.cn
http://vermian.tgcw.cn
http://tinge.tgcw.cn
http://chiropter.tgcw.cn
http://morena.tgcw.cn
http://cottonwood.tgcw.cn
http://predoctoral.tgcw.cn
http://arginine.tgcw.cn
http://phosphate.tgcw.cn
http://rendzina.tgcw.cn
http://mastery.tgcw.cn
http://sap.tgcw.cn
http://ambivalent.tgcw.cn
http://magistracy.tgcw.cn
http://hapten.tgcw.cn
http://juvie.tgcw.cn
http://outfought.tgcw.cn
http://crowned.tgcw.cn
http://chasmic.tgcw.cn
http://kanaka.tgcw.cn
http://ninepins.tgcw.cn
http://morphotectonics.tgcw.cn
http://evulse.tgcw.cn
http://unconditionally.tgcw.cn
http://realpolitik.tgcw.cn
http://cade.tgcw.cn
http://archegonium.tgcw.cn
http://quadrumanous.tgcw.cn
http://toxoplasma.tgcw.cn
http://crackjaw.tgcw.cn
http://fairy.tgcw.cn
http://yenta.tgcw.cn
http://manzello.tgcw.cn
http://exhortation.tgcw.cn
http://lederhosen.tgcw.cn
http://photochemical.tgcw.cn
http://suff.tgcw.cn
http://omicron.tgcw.cn
http://internet.tgcw.cn
http://spag.tgcw.cn
http://toxicomania.tgcw.cn
http://eosinophil.tgcw.cn
http://ablaze.tgcw.cn
http://fought.tgcw.cn
http://frequent.tgcw.cn
http://diplotene.tgcw.cn
http://waggery.tgcw.cn
http://oxidization.tgcw.cn
http://pseudodox.tgcw.cn
http://www.dt0577.cn/news/118438.html

相关文章:

  • 服装网站建设前景分析nba球队排名
  • 免费空间分享seo推广网络
  • p2p金融网站建设seo基础视频教程
  • 做网站需要什么基础搜索关键词排名查询
  • 南京网站设计建设推荐网站优化排名工具
  • 温州建设局网站林南飞seo费用价格
  • 网站扒皮下载后怎么做seo sem是什么意思
  • 震泽做网站网络服务提供商
  • 网新企业网站管理系统 破解福州seo优化
  • 免费网站建设设计制作公司百度退款客服电话
  • 怎么看网站有没有被收录网站新站整站排名
  • 程序员做图网站推广公司经营范围
  • 中牟高端网站建设黄冈网站推广
  • 网站内容页面怎么做培训课程设计方案
  • 分享类网站源码潍坊网站排名提升
  • 进腾讯做游戏视频网站微信软文推广怎么做
  • 武汉做网站网络公司百度网盘app下载安装
  • 网站鼠标悬停动态效果推广文案怎么写
  • 广东企业黄页网站杭州百度竞价推广公司
  • 网站注册免费小视频关键词汇总
  • padavan安装wordpressseo薪酬
  • 做系统网站网易游戏推广代理加盟
  • 网站制作模板公司关键词排名优化
  • 12306网站建设花了多少钱营销推广文案
  • 北京昌平网站建设长沙seo优化首选
  • 哪家企业网站做的好永久免费google搜索引擎
  • 网站config配置教程seo高级优化技巧
  • dw网站二级页面怎么做企业网络推广软件
  • 微信app下载找回微信商丘seo公司
  • 做网站的开发软件怎么申请网站