zoukankan      html  css  js  c++  java
  • Java线程状态:BLOCKED与WAITING的区别

    Doc说明:

        /**
         * Thread state for a thread blocked waiting for a monitor lock.
         * A thread in the blocked state is waiting for a monitor lock
         * to enter a synchronized block/method or
         * reenter a synchronized block/method after calling
         * {@link Object#wait() Object.wait}.
         */
        BLOCKED,
    
        /**
         * Thread state for a waiting thread.
         * A thread is in the waiting state due to calling one of the
         * following methods:
         * <ul>
         *   <li>{@link Object#wait() Object.wait} with no timeout</li>
         *   <li>{@link #join() Thread.join} with no timeout</li>
         *   <li>{@link LockSupport#park() LockSupport.park}</li>
         * </ul>
         *
         * <p>A thread in the waiting state is waiting for another thread to
         * perform a particular action.
         *
         * For example, a thread that has called <tt>Object.wait()</tt>
         * on an object is waiting for another thread to call
         * <tt>Object.notify()</tt> or <tt>Object.notifyAll()</tt> on
         * that object. A thread that has called <tt>Thread.join()</tt>
         * is waiting for a specified thread to terminate.
         */
        WAITING,
    

    BLOCKED是指线程正在等待获取锁;WAITING是指线程正在等待其他线程发来的通知(notify),收到通知后,可能会顺序向后执行(RUNNABLE),也可能会再次获取锁,进而被阻塞住(BLOCKED)。

  • 相关阅读:
    CSS基本知识(慕课网)
    html基本标签(慕课网)
    我为什么要写博客
    Android项目实战(三十二):圆角对话框Dialog
    02-05 scikit-learn库之线性回归
    02-36 支持向量回归
    02-25 scikit-learn库之决策树
    02-29 朴素贝叶斯(垃圾邮件分类)
    C-02 推荐系统
    05-02 特征选择
  • 原文地址:https://www.cnblogs.com/riordon/p/5775236.html
Copyright © 2011-2022 走看看