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

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

  •  
  •   luxinfl · Dec 8, 2020 · 1419 views
    This topic created in 1989 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   ·   1389 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 17:12 · PVG 01:12 · LAX 10:12 · JFK 13:12
    ♥ Do have faith in what you're doing.