Question: Java Help: This is part 4 of a 5 part question so 5 likes on offer. Part 1: https://www.chegg.com/homework-help/questions-and-answers/java-help-part-1-5-part-multithreading-question-5-likes-offer-part-2-https-wwwcheggcom-hom-q69755166 Part 2: https://www.chegg.com/homework-help/questions-and-answers/java-help-part-2-5-part-question-5-likes-offer-part-1-part-3-part-4-part-5-part-done-2nd-p-q69755173 Part 3: https://www.chegg.com/homework-help/questions-and-answers/java-help-part-3-5-part-question-5-likes-offer-part-1-part-2-part-4-part-5-part-done-3rd-p-q69755184
Java Help: This is part 4 of a 5 part question so 5 likes on offer. Part 1:
https://www.chegg.com/homework-help/questions-and-answers/java-help-part-1-5-part-multithreading-question-5-likes-offer-part-2-https-wwwcheggcom-hom-q69755166
Part 2:
https://www.chegg.com/homework-help/questions-and-answers/java-help-part-2-5-part-question-5-likes-offer-part-1-part-3-part-4-part-5-part-done-2nd-p-q69755173
Part 3:
https://www.chegg.com/homework-help/questions-and-answers/java-help-part-3-5-part-question-5-likes-offer-part-1-part-2-part-4-part-5-part-done-3rd-p-q69755184
Part 5:
https://www.chegg.com/homework-help/questions-and-answers/java-help-part-5-5-part-question-5-likes-offer-part-1-part-2-part-3-part-4-part-done-last--q69755214
This part should be done 4th. Please use Book.java, Bookstore.java, Buyer.java from prior part solutions.
Part 4: Seller.java
This class will represent customers who wish to sell books to the store. Each instance of Seller will run as a separate thread, and so the Seller class should implement the Runnable interface.
Each Seller instance should be assigned a unique ID when it first tries to interact with the Bookstore (i.e. when its run() method is called). Static thread safe fields (e.g. instances of AtomicInteger) should be used to count the total number of sellers created, and the total number of sales successfully completed.
The Seller constructor should accept an instance of Bookstore as an argument, and then store the reference to this object in a private field.
The Seller run() method should attempt to buy a Book from the store. It should first check that the Bookstore has space available for another Book (by calling the .isFull() method of the Bookstore instance). If there is no space available, the Seller should wait until a space becomes available before proceeding. The Seller should then proceed to add its Book instance to the Bookstore. Once a Seller has successfully completed a sale, its run() method can terminate (i.e. the thread has finished its work).
Some of the operations in the run() method should be made thread safe to prevent race conditions (e.g. two sellers trying to sell books at the same time and causing the Bookstore capacity to be exceeded). Your answer should use the wait() and notify()/notifyAll() methods.
A message should be printed to the console each time a new Seller reaches the store (directly after its run() method is called), each time a Seller waits to sell a Book, and each time a Seller successfully sells a Book to the Bookstore (see example program output in part 5).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
