Class BlockingBufferTest
Class BlockingBufferTest
(Fig. 23.15) contains the main
method that launches the application. Line 13 creates an ExecutorService
, and line 16 creates a BlockingBuffer
object and assigns its reference to the Buffer
variable sharedLocation
. Lines 18–19 execute the Producer
and Consumer Runnable
s. Line 21 calls method shutdown
to end the application when the threads finish executing the Producer
and Consumer
tasks and line 22 waits for the scheduled tasks to complete.
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.