This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Prakash, I wrote a standalone test program spawning threads in a loop to make remote calls. Keep in mind that you will not be reusing the remote object you got from the firt call. Every thread will get ask for a new instance of remote object from the RMI server. Think about probably 7 various test cases and test them.
It is also easy to test by putting either a call to Thread.sleep() or System.in.readLine() (a handy way to pause a program) between your calls to lock() and unlock(). Then if you run 2 different instances of the client against one server and try to book seats on the same flight, being sure to have the second client start booking while the first client has the flight locked, you should see afterward that the second client shows the correct total number of seats, while the first client is not yet aware of the seats the second one booked. Does that make sense? I hope that helps.
Personally I included a "Traffic Cop" test mode (menu selectable) that locks, then throws up a dialog box before continuing on. My lock mechanism notes the time that the lock was acquired, as well as a clientID (the remote stub reference), and a "progress" counter. If a client has gone comotose (i.e., not made any progress in 60 seconds, beyond acquiring the lock), the server can give its lock to a second client that comes along requesting that lock. Server shutdown also checks for comotose clients, and gives you the option of "pulling the plug" on them- hence allowing any blocked clients to finish. That locking mechanism is fancier than what's really required, but still the Traffic Cop is a neat way to test the locking mechanism, since it gives you direct control over it.
Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>