Final answer:
To create a PostalWorkerThread class that extends Thread and implements the required functionalities, you can follow these steps: Define the class and extend Thread, acquire and release the postalWorkerMutex semaphore, include and use the scalesMutex semaphore, and add print statements to match the specified output format.
Step-by-step explanation:
PostalWorkerThread class
To create a PostalWorkerThread class that extends Thread, you can define the class as follows:
public class PostalWorkerThread extends Thread {
// class implementation
}
Acquiring and Releasing Semaphores
To acquire the postalWorkerMutex semaphore and enter the critical section, you can use the acquire() method:
postalWorkerMutex.acquire();
// critical section
postalWorkerMutex.release();
Using scalesMutex Semaphore
Include the scalesMutex semaphore in your code by acquiring and releasing it in a similar manner:
scalesMutex.acquire();
// code for using the scales
scalesMutex.release();
Adding Print Statements
Use print statements to match the output format mentioned in the project description. For example:
System.out.println("Postal worker serving customer: " + customerId);