Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i want code within an hour please Write a Java multi-threaded program to simulate multiple people passing through a grotto (small cave) in search of
i want code within an hour please
Write a Java multi-threaded program to simulate multiple people passing through a grotto (small cave) in search of a magical box containing treasures. This grotto can only pass one person at a time, and the time for each person takes 3 seconds (sleep) to pass through it. There are seven persons, all of them try to pass through the grotto. Each person is associated with the name represented by the string and the name of the person who passes the grotto is printed out each time. There are 'n' boxes, each box will be identified by a unique integer value and one of them is a magical box that is identified by a prime number. The grotto will instantly close if any person finds the magical box. Create appropriate threads that replicate the scenario described using interthread communication. Incorporate wait() and notify() of thread class methods and introduce sufficient sleep() to simulate the aboveStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started