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)。

  • 相关阅读:
    2018-2-26 php、mysql数据库制作简单的商城购物车
    2018-2-8 租房信息的增删改和搜索
    2018-2-6 留言板的制作
    ztree连接数据库问题总结
    织梦cms
    MySQLDB.class.php
    类和对象
    构造、析构;重写;设计模式;单例;抽象;重载
    类、面向对象、类的继承
    css 区块与盒子模型
  • 原文地址:https://www.cnblogs.com/riordon/p/5775236.html
Copyright © 2011-2022 走看看