zoukankan      html  css  js  c++  java
  • 今日小结 4.18

    • 多线程Demo  OK
    • 获取蓝牙数据,显示温度
    • 中期报告

    1.post 张贴;发帖子,挂在网上;邮件,邮寄;标杆,柱子。

    相似的有 pending 未决定的,悬而未决的,挂起的(还未执行,即将执行的),搁置的

    pending表状态,表明事件是挂起的,还未执行但即将执行的

    post 表动作, 一般指“挂到”事件队列中,表动作

    (ex1)

    If the current thread is not the UI thread,         //如果当前线不是UI线程(主线程),则
    the action is posted to the event queue of the UI thread.  //这个事件将被挂在UI线程的事件队列  //队列就是排队买饭,先到先吃,后到后吃,所以这个新到的事件会被排在(挂在事件队列的最后,就像被post ,被贴上去一样)
        /**
         * Runs the specified action on the UI thread. If the current thread is the UI
         * thread, then the action is executed immediately. If the current thread is
         * not the UI thread, the action is posted to the event queue of the UI thread.
         *
         * @param action the action to run on the UI thread
         */
        public final void runOnUiThread(Runnable action) {
            if (Thread.currentThread() != mUiThread) {
                mHandler.post(action);
            } else {
                action.run();
            }
        }

    (ex2)

    延时挂起 postDelayed 

    即执行到这个handler时,将事件r 加入消息队列,延时2000ms后再挂到当前线程中的事件队列

    public final boolean postDelayed (Runnable r, long delayMillis)
    Added in API level 1
    Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses. The runnable will be run on the thread to which this handler is attached. The time-base is uptimeMillis(). Time spent in deep sleep will add an additional delay to execution.
            /*开线程*/
            new Handler().postDelayed(new Runnable() {          //使任务延时执行
                @Override
                public void run() {
                    Log.d("mylog","进入了run(),开始loadData()");
                    mainPresenter.loadData();
                    Log.d("mylog","loadData() 结束");
                }
            },2000);
  • 相关阅读:
    C#中关于@的用法
    c++ 中__declspec 的用法
    #pragma详细解释(一)
    memmove 和 memcpy的区别
    【niubi-job——一个分布式的任务调度框架】----安装教程
    [异能程序员]第一章 酒后事发(第一更)
    博客园的最后一篇博文,还是要离开了(附带个人博客源码分享)
    五一假期——技术之路上的坎儿
    deerlet-redis-client添加集群支持,邀请各路大神和菜鸟加入。
    从日常开发说起,浅谈HTTP协议是做什么的。
  • 原文地址:https://www.cnblogs.com/Chongger/p/5404665.html
Copyright © 2011-2022 走看看