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);
  • 相关阅读:
    如何在SQLite中创建自增字段?
    Windows XP平台下编译boost[1.47及以上]
    智能指针的向下转型
    采用Boost::filesystem操作文件
    CodeSmith访问数据库
    std::string的一些操作
    PDF加入内嵌字体
    悟空和唐僧的对话
    收获和教训的一天配置ds1401
    vxworks的一个changlog
  • 原文地址:https://www.cnblogs.com/Chongger/p/5404665.html
Copyright © 2011-2022 走看看