it says "Assume that read() is started by one thread and write() is started by another thread.if there are two different thrads thay may read and write independently,there is a risk of deadlock at line 8 or 16.
I tried to execute the above program with two thread.but i am having trouble how to start two new threads calling read() and write() methods.please help me on this.
To be doubly sure have a sleep method between the synchronizations
Joined: Jan 05, 2006
Thanks for the answer swarna.
so without creating an anonymous inner class,i don't think this program running in two different threads calling read() and write() method is possible.Am i correct?
Joined: Mar 15, 2007
Objective - one thread needs to run read and the other write. This can be done by the following:- 1) Anonymous class 2) Non static Inner class 3) Static Nested class 4) Create 2 subclasses A1 and A2 extending Chapter9, one calling read and the other calling write in run method.
These are the only ways i think we can run the required scenario.