logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

you with the creation and execution of threads, and with the use of the Thread’s class methods. In order to synchronize the threads you will have to use run( ), start( )

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

The project must be done individually with no other source(s). No exceptions.

Read the Academic Integrity link one more time.

Through its implementation, this project will familiarize you with the creation and execution of threads, and with the use of the Thread’s class methods. In order to synchronize the threads you will have to use (when necessary), run( ), start( ), currentThread( ), getName( ), join( ), yield( ), sleep(time), isAlive( ), getPriority( ), setPriority( ), interrupt( ), isInterrupted( ), and maybe synchronized methods.

In synchronizing threads, DO NOT use any semaphores. DO NOT use wait( ), notify( ) or notifyAll();

Tourists go to Ellis Island to learn about the beginnings of America, and sometimes to try to find out about their ancestors who immigrated to this country.

Every half hour a documentary movie is presented. If the movie is in session, visitors busy wait in the lobby of the movie theatre. When the previous session ends (announced by a clock thread), visitors hurry up to enter the theater and take one of the available seats (simulate this by increasing the priority of the visitor; after a sleep of random time, set its priority to its default value; use getPriority() and setPriority() methods)

If there are no free seats, visitors leave the room, and will wait to see the next presentation (you can implement the mutual exclusion over the shared variable free seats by having it access through a synchronized method, or by declaring it as volatile. Make sure that if you use synchronized methods you never have a thread sleep inside of them). On their way out, they want to be polite at the door, so visitors yield to each other (use yield() twice). Once the movie starts, no visitor can enter and disturb it.

While the movie is on visitors sleep for a long time (the only way to get out of sleep will be by an interrupt).

Your display should clearly show who got in the theater, who left, and who was able to see the current presentation.

When the movie ends (announced by a clock), a speaker will wake up the visitors by sending an interrupt to each visitor in the theater (use the interrupt() method. To check that it works, have a message part of the catch block).

Next, as a reward, the speaker gives out sets of party_tickets for a future movie. The audience will gather into groups of party_tickets size (maybe you want to use a Boolean

 

array/vector) and busy wait to be called. The speaker will call each group at once and distribute the tickets. After that, the speaker will busy wait for the end of the next movie.

Next the visitors will browse around for a while and eventually leave the theater. They leave in the order of their ID (let’s say in the theater you have T3, T5, T2 and T1. The order in which they leave is T1, T2, T3, T5. Use the isAlive() and join() methods.

In order to keep track of the time, we need an additional thread, named clock. The clock will signal the start time of the next movie and the end time of the previous movie, (between sessions the clock will sleep for a fixed time).

Throughout the day, they are four movie presentations. The speaker will terminate after the visitors of the last presentation leave the theater. The visitors terminate after they leave the theater or if they didn’t have the chance to see a presentation, when the museum closes.

Shortly after the four presentations end, the clock announces the closing of the museum, and terminates.

Initial values: numVisitors = 23

theaterCapacity = 5

party_ticket =3

The numVisitors should be an argument to the program.

Using the synchronization tools and techniques learned in class, synchronize the visitor threads, speaker and clock threads – in the context of the problem described above.

In order to simulate different actions you must pick reasonable intervals of random time. Make sure that the execution of the entire program is somewhere between 40 seconds and 90 seconds.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Atharva PatilComputer science

549 Answers

Hire Me
expert
Chrisantus MakokhaComputer science

714 Answers

Hire Me
expert
AyooluwaEducation

728 Answers

Hire Me
expert
RIZWANAMathematics

540 Answers

Hire Me

Get Free Quote!

445 Experts Online