Section 23.8 (Advanced) Producer/Consumer Relationship: Bounded Buffers

• You cannot make assumptions about the relative speeds of concurrent threads.

• A bounded buffer (p. 995) can be used to minimize the amount of waiting time for threads that share resources and operate at the same average speeds. If the producer temporarily produces values faster than the consumer can consume them, the producer can write additional values into the extra buffer space (if any are available). If the consumer consumes faster than the producer produces new values, the consumer can read additional values (if there are any) from the buffer.

• The key to using a bounded buffer with a producer and consumer that operate at about the same speed is to provide the buffer ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.