If you are asking whether the locking code can exist in some other class than the Data class - I believe it can be, as long as the Data class acts as a front end to the locking methods (Facade pattern).
If you are asking whether methods that call the Data class' locking methods can be synchronised (or can contain synchronized blocks) - why not?
Hi Andrew, My question is you have to provide locking mechanism in Data.java class (it is must according to above quote from assignment document) If you provide them in other class then SUN will fail you. So you have to provide all locking in Data.java and provide wrapper class to access all methods of Data.java
kind of answer myself but need validation from you.
author and jackaroo
Originally posted by Ken Boyd So you have to provide all locking in Data.java
When you have completed your coding of the Data class then any user of the Data class (whether the server you write, or some other programs that somebody else writes) must be able to call the lock methods of your Data class and obtain a logical lock on the requested record (or block until the logical lock is available).
Originally posted by Ken Boyd So you have to [...] provide wrapper class to access all methods of Data.java
Personally I agree with that statement. However there are many who disagree. You might like to take a look at the topic "Should lock methods be callable by the client" for arguments for and against this position. It is worth noting that candidates do not appear to loose marks for not having such wrapper classes.
Joined: Dec 10, 2003
I know Eric(65515) got fail because he didn't provide locking in Data.java (instead in wrapper class). So it is must to have locking in Data.java, so SUN can directly test it using other program or software. I will provide wrapper class with different method name which in turn calls lock & unlock methods of Data.java.