Can someone please comment if it makes sense - I got lost (a bit): My assignment DBMain interface defines: 'public void lock(int recNo) throws RecordNotFoundException' - the comments say this: "Locks a record so that it can only be updated or deleted by THIS CLIENT. If the specified record is already locked, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked." I am not sure what 'this client' means. At first I thought it means some id the server issues each client for identification - but the method does not allocate any argument for this. Then I thought perhaps they mean identification by the thread name - now I am lost... Can any body figure this out? Please?
Tom Silverman: SCJP5, SCJD6, SCWCD5, SCBCD5, IBM-142, ScrumMaster
I am not sure what 'this client' means The current executing thread, or more simply the remote client connected to the server. [ November 02, 2008: Message edited by: Justin Rundle ]
Joined: Nov 01, 2008
Thank you Justin for replying. I wish I knew. This is my question. 'This Client' is what the instructions say. What do you make of this? If this is the current thread - can I identify it by its name? If this is the client identifier - how am I to pass this argument, say, for the 'public void lock(int recNo) throws RecordNotFoundException' method?
how am I to pass this argument, say, for the 'public void lock(int recNo) throws RecordNotFoundException' method? You are not required to change the method signature. If you want to use the current executing thread to identify the locked record, of which I can recommend, maybe you could use:
You need to come up with a way to identify a client by the server. Not necessarily, this requirement is dependent of the specification for the assignment as some version related to a cookie no. of sorts. Whereas a method signature as discussed is pertinent to only using the recNo variable, therefore idenitifying the client mightn't be necessary.
Joined: Jul 02, 2004
Having passed SCJD, i am not about to divulge how to do it, but you will have a layer of business logic in there...