Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operating System Concepts with Java. Please help! CAIS-0339 Homework #5 General Description Write a Java program Factory that starts the following three threads. 1. 3

Operating System Concepts with Java. Please help! image text in transcribed
image text in transcribed
CAIS-0339 Homework #5 General Description Write a Java program Factory that starts the following three threads. 1. 3 Producer threads (id'ed 0, 1, and 2) 2. 3 Consumer threads (id'ed 0, 1, and 2) 3. 1 Timer thread The producers and the consumers must communicate through a bounded buffer with buffer size 5 In particular, the producers repeat the following sequence of actions. 1. Sleeps for a random amount of time ranging from 0 to 8 seconds. 2. Inserts into the buffer an object (of class Bufferltem) that stores the producer id and a sequence number. For instance, (0,2) represents an object with a sequence number 2 and inserted by producer 0. The sequence number for each producer tarts from 0, and increments by 1 each time after an object has been inserted. Concurrently, the consumers repeat the following sequence of actions. 1. Sleeps for a random amount of time ranging from 0 to 10 seconds. 2. Removes a Bufferltem object from the buffer, and displays it. The timer gives the producer and the consumer threads to execute for 1 minute, and then, causes the entire program to terminate by calling System.exit (0) The producers and the consumers must report on the Bufferltem objects as they insert or remove them. The BoundedBuffer class must use synchronized, wait, and notifyotify All to ensure that the BoundedBuffer is accessed in a mutually exclusive manner

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

ISBN: 978-0764535376

More Books

Students also viewed these Databases questions