Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please guys in java help me ( the course is operating system by using ubuntu ) From what you have learned in lab, construct a

image text in transcribedplease guys in java help me ( the course is operating system by using ubuntu )

From what you have learned in lab, construct a multithreaded program to simulate the print jobs of a printer, one job at a time, your program should include the following: - A shared object called a Buffer that is initially empty. - Set1 of threads, to put data in the buffer (Write Jobs) with 1/2 second delay. - Set2 of threads, to read data from the buffer (Read Jobs) with one second delay. - The Buffer should be empty upon exiting the program. - You should not allow reading jobs from the buffer if there is none existing. - You should not allow writing new jobs if the buffer is full (say have a maximum of 20 jobs) - Deal with race conditions. - Avoid deadiocks. Use the following main class and the sample output as a guide to complete the tasks above, \begin{tabular}{lll|l} \hline Open * & FI & Tain.jova & Sa \\ \hline \end{tabular} 1 pubtte class Maint 2 publte statte void nain(string[] afgs)\{ 3 Buffer Printer = new Buffer(); 4. for (int 1=1;120;1++) i The table below shows the tasks required along with the marks allocated for each 5 writeRunnable NriteJob = new kriterunnable(Printer); thesk. 6 ReadRunnable Readjob = new ReadRunnable(Prtnter); 7 Thread writethread a new Thread(Writejob); 8 Thread ReadThread = new 10 Readthread.start(): Ubreotice Witer 13} Assignment group: Your choice of working by yourself or in groups of four. BlackBoard Submission: - The source lava files for the classes in your program - A document file that includes your names \& IDs plus a summary explaining what you have done in your program formatted as follows, - Where the race condition is happening in the program and why, - How you dealt with the race condition. - Why and how the deadlock happened and how it was avoided

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions