February 2014
Beginner
1248 pages
62h 25m
English
Class CircularBufferTest (Fig. 23.19) contains the main method that launches the application. Line 12 creates the ExecutorService, and line 15 creates a CircularBuffer object and assigns its reference to CircularBuffer variable sharedLocation. Line 18 invokes the CircularBuffer’s displayState method to show the initial state of the buffer. Lines 21–22 execute the Producer and Consumer tasks. Line 24 calls method shutdown to end the application when the threads complete the Producer and Consumer tasks and line 25 waits for the tasks to complete.
Read now
Unlock full access