Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This activity will enable you to apply what you learn during this course. In this assignment, you will write, test, and debug a Java program

This activity will enable you to apply what you learn during this course. In this assignment, you will write, test, and debug a Java program or any other programming language you prefer that contains two threads Professor and StudentScheduler.

Professor Smith is seeing students during office hours at NYU. She can only see one student at a time, and students will wait patiently outside while another student is with the professor. There are exactly five chairs outside the professors office. If all the chairs are full, no more students may wait outside. But they can come back later and check to see if a chair has opened up.

An office visit can take anywhere from 1 to 5,000 milliseconds. When a student exits the professors office, the student who is in the first chair may enter. The rest all slide down. This continues until there are no more students who need to see the professor.

Write, test, and debug a program in Java that contains two threads: Professor and StudentScheduler. The StudentScheduler thread will create new Student objects at random intervals and place them in a shared memory queue of maximum length 5. Each Student object contains the Students name and the amount of time he/she needs to spend with the Professor. If the queue is full, the StudentScheduler thread will wait and not produce any more Students until there is a free spot in the queue. The Professor thread will remove Student objects from the queue and meet with each Student for the necessary length of time. If there are no Students in the queue, the Professor will play Halo on her computer until a new Student arrives. The Professor will leave and lock her office when there are no more Students to see for the day (she will know this because the StudentScheduler thread will terminate). The StudentScheduler thread will create a minimum of 15 and a maximum of 300 students.

Be sure to use synchronized methods or code blocks where appropriate to avoid concurrency anomalies.

Submission Guidelines

In a Word document, paste screenshots of your code and successful execution. Combine the Word document, your entire solution, and any necessary files together and submit as a single ZIP file.

Use the American Psychological Association (APA) style (6th edition) for writing your assignment.

Compose your work in a .doc or .docx file type using a word processor (such as Microsoft Word, etc.) and save it frequently to your computer.

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

Students also viewed these Databases questions

Question

Evaluating Group Performance?

Answered: 1 week ago