• 请不要在回答技术问题时复制粘贴 AI 生成的内容
luxinfl
V2EX  ›  程序员

为什么 ArrayBlockingQueue 这两个条件参数名这么难理解

  •  
  •   luxinfl · Dec 8, 2020 · 1428 views
    This topic created in 1991 days ago, the information mentioned may be changed or developed.
    /** Condition for waiting takes */
    private final Condition notEmpty;
    
    /** Condition for waiting puts */
    private final Condition notFull;
    

    当 put 的时候,如果队列满了,会调用 notFull.await() 为什么 notFull 这个参数不换成类似 producer.await()更好理解么? 同理当队列为空 take 的时候,notEmpty.await()换成 cosumer.await()。唤醒生产者的时候调用 producer.singal()

    1 replies    2020-12-09 08:55:49 +08:00
    xmt328
        1
    xmt328  
       Dec 9, 2020
    我觉得没问题啊,谁规定 blocking queue 就只能用在生产者消费者模式
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3900 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 00:12 · PVG 08:12 · LAX 17:12 · JFK 20:12
    ♥ Do have faith in what you're doing.