Question: Kindly accomplish this activity using Java with File I/O. Create two threads running at the same time and implement mutex. With two threads one is

Kindly accomplish this activity using Java with File I/O. Create two threads running at the same time and implement mutex. With two threads one is reading and one is writing or viceversa. Use Try Catch Block for exceptions, errors. General Instruction: The file should be lock if it is being written. if the other other thread is trying to read it. It will be unlocked only if the two threads are reading it. Always display time when reading and writing. How much time taken doing the process. T1 - read unlock state T2 -read unlock state T1 - write lock state, show the timer 10 secs or duration/ real-time when you write T2 - lock the file when T2 trying to read and T1 is writing. Prompt T1 is still writing then if T1 is finish writing display T2 - lock the file when T2 trying to read and T1 is writing. Prompt T1 is still writing then if T1 is finish writing display time when it finish writing. then allow T2 to read. Display time when it finish reading then display text read. T1 - write lock until it is finish, how much time does it take to finish. when finish T2 will be allowed to modify T2 - write
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
