Question: Ticket Booking System with ReentrantLock Create a program that simulates a theater ticket booking system where multiple users ( threads ) try to book seats

Ticket Booking System with ReentrantLock
Create a program that simulates a theater ticket booking system where multiple
users (threads) try to book seats simultaneously.
The Theater class should represent the seating arrangement and have methods for
booking seats. Use reentrant locks to ensure that a seat cannot be double-booked.
Implement a bookSeat(int seatNumber) method in the Theater class that marks
a specific seat as booked. If the seat is already booked, the method should print
a message indicating that the seat is unavailable. Use reentrant locks to prevent
multiple threads from booking the same seat simultaneously.
Add a feature where, if a seat is unavailable, the thread is added to a waiting list
(simulated with a queue). If the seat becomes available, the first thread in the
waiting list should be notified.
Add a timeout feature where a thread attempts to book a seat only for a limited
amount of time. If it cannot acquire the lock within the timeout, it should cancel
the booking attempt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!