CS340 Project 1 SP19The 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 ofthreads, and with the use of the Threads class methods. In order to synchronize the threadsyou will have to use (when necessary), run( ), start( ), currentThread( ), getName( ), join( ),yield( ), sleep(time), isAlive( ), getPriority( ), setPriority( ), interrupt( ), isInterrupted( ), andmaybe synchronized methods.In synchronizing threads, DO NOT use any semaphores. DO NOT use wait( ), notify( ) ornotifyAll();Tourists go to Ellis Island to learn about the beginnings of America, and sometimes totry 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, visitorsbusy 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 theavailable seats (simulate this by increasing the priority of the visitor; after a sleep ofrandom 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 nextpresentation (you can implement the mutual exclusion over the shared variable freeseats 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 insideof them). On their way out, they want to be polite at the door, so visitors yield to eachother (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 willbe by an interrupt).Your display should clearly show who got in the theater, who left, and who was able tosee the current presentation.When the movie ends (announced by a clock), a speaker will wake up the visitors bysending an interrupt to each visitor in the theater (use the interrupt() method. To checkthat 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. Theaudience will gather into groups of party_tickets size (maybe you want to use a Booleanarray/vector) and busy wait to be called. The speaker will call each group at once anddistribute 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. Theyleave in the order of their ID (lets say in the theater you have T3, T5, T2 and T1. Theorder 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 clockwill 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 afterthe visitors of the last presentation leave the theater. The visitors terminate after theyleave the theater or if they didnt have the chance to see a presentation, when themuseum closes.Shortly after the four presentations end, the clock announces the closing of themuseum, and terminates.Develop a monitor synchronization of the three types of threads: speaker, visitors, clockin the context of the problem.Initial values: numVisitors = 23theaterCapacity = 5party_ticket =3The 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. Makesure that the execution of the entire program is somewhere between 40 seconds and 90seconds.Guidelines1. Do not submit any code that does not compile and run. If there are parts of the code thatcontain bugs, comment it out and leave the code in. A program that does not compile nor runwill not be graded.2. Closely follow all the requirements of the Projects description.3. The Main class is run by the main thread. The other threads must be manually specified byeither implementing the Runnable interface or extending the Thread class. Separate theclasses into separate files. Do not leave all the classes in one file. Create a class foreach type of thread. Dont create packages.4. The program asks you to create different types of threads. When there is more than oneinstance of the thread, no manual specification of each threads activity is allowed (e.g. noClerk1.checkCustomer()).5. Add the following lines to all the threads you make:public static long time = System.currentTimeMillis();public void msg(String m) {System.out.println([+(System.currentTimeMillis()-time)+] +getName()+: +m);}It is recommended to initialize time at the beginning of the main method, so that it will be uniqueto all threads.6. There should be printout messages indicating the execution interleaving. Whenever you wantto print something from that thread use: msg(some message about what action is simulated);7. NAME YOUR THREADS or the above lines that were added would mean nothing.Heres how the constructors could look like (you may use any variant of this as long as eachthread is unique and distinguishable):// Default constructorpublic RandomThread(int id) {setName(RandomThread- + id);}8. Design an OOP program. All thread-related tasks must be specified in its respective classes,no class body should be empty.9. No implementation of semaphores or use of wait( ), notify( ) or notifyAll( ) are allowed.10. thread.sleep() is not busy wait. while (expr) {..} is busy wait.11-12. DO NOT USE System.exit(0); the threads are supposed to terminate naturally by runningto the end of their run methods.13. The program should allow easy change to the default values. Do not hard-code yourprogram.14. Javadoc is not required. Proper basic commenting explaining the flow of the program, selfexplanatoryvariable names, correct whitespace and indentations are required.Tips:-If you run into some synchronization issues, and dont know which thread or threads arecausing it, press F11 which will run the program in debug mode. You will clearly see the threadnames in the debug perspective.Setting up project/Submission:In Eclipse:Name your project as follows: LASTNAME_FIRSTNAME_CSXXX_PYwhere LASTNAME is your last name, FIRSTNAME is your first name, XXX is your course, andY is the current project number.For example: Doe_John_CS340_p1To submit:-Right click on your project and click export.-Click on General (expand it)-Select Archive File-Select your project (make sure that .classpath and .project are also selected)-Click Browse, select where you want to save it to and name it asLASTNAME_FIRSTNAME_CSXXX_PY-Select Save in zip format (.zip)-Press FinishPLEASE UPLOAD YOUR FILE ON BLACKBOARD ON THE CORRESPONDING COLUMN.The project must be done individually with no use of other sources including Internet.No plagiarism, No cheating.
Only logged in customers who have purchased this product may leave a review.

![[Solved] CS340 Project 1 SP19](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] CS340 Project 1 SP19](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.