如果有轻微的扭曲支持一个空的队列满的,管道将很少填补和读者经常会收到新的号码。
If there is a slight skewing favoring an empty queue over a full one, the pipe will rarely fill and the reader will more often receive fresh Numbers.
相反,如果大小有限的队列满了,那么offer方法会返回false,而不需要处理队列满的异常。
Instead, if a sized queue was full, the offer method returns false, not causing you to deal with exceptions when full.
队列是BlockingCollection,它非常适合这个模块:在队列满时,阻塞生产者线程,当队列空时,阻塞消费者线程。
The queue is BlockingCollection which perfectly suits the needs of this module: it blocks the producer thread if the queue is full and blocks the consumer thread when queue is empty.
应用推荐