Originally posted by Jaro Prospal:
Hi,
Is it possible to appeal the grading result?
:-) yes, I failed. Zero points in locking. But, I don't think the
tester is right. The explanation - "Your locking method does not block when trying to lock a locked record." - is not true.
Pretty arrogant from me, hmm? :-)
I believe what I see in the code and it is a classic wait-pattern.
What should I do :-)
Greetings
Jaro
SCJP<br />SCJD
The explanation - "Your locking method does not block when trying to lock a locked record." - is not true.
Pretty arrogant from me, hmm? :-)
I believe what I see in the code and it is a classic wait-pattern.
Originally posted by Jaro Prospal:
Thanks for your interest.
Well, maybe I am going to blame myself, but after all I did it already :-)
Here is the piece from Data class.
The synchronizes on the member lockedRecords. If it gets the monitor, it checks if the record
is locked. The method waitUntilRecordIsNotLocked returns true if the record is unlocked and
false is already locked by the same thread (for instance by calling the lock method twice).
I have to say, the implementation of the sequence lock, update, unlock reside on the server
("thin" client), so I identify the clients by the thread reference.
Data class is singleton.
I really don't know what is there wrong.
[Andrew: put code between [code] and [/code UBB tags]
[ November 09, 2006: Message edited by: Andrew Monkhouse ]
SCJP<br />SCJD
There's no need for that - you only need to notify other threads when there is a reason for them to re-check whether their lock is now available - in other words, at the end of your unlock() method.Originally posted by Mark Smyth:
[...] and you should probably also have a notifyAll() at the end of the lock method to inform other threads that you are finished with the monitor. [...]
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
42
It looks like your thread will get the mutex on the LockMap object twice while performing a lock operation - while this wont cause a problem, it is generally not desirable.
SCJP, SCJD, SCWCD, OCPJBCD
You may assume that at any moment, at most one program is accessing the database file;
therefore your locking system only needs to be concerned with multiple concurrent clients of your server.
remote calls of lock and unlock from
clients.
Originally posted by Jaro Prospal:
Hi Radu,
yes, you right and I was thinking about this case.
But,in my case, all the lock, update, unlock logic resides on the server. Some folks here call it "thin" client.
Thus, a thread processes the three calls for one request and then can go to process other ones.
On the other side, the testers can test the code the way you described - remote calls of lock and unlock from
clients. In that case, it may happen that the code does not work, as you described. But, these tests seems to
me against the claim in the assignment:
The tests can be considered as another server and for that server the locking mechanism is not required to work.
Another point is, I have no idea how to transport some client IDs through the API.
Greeting
Jaro
SCJP<br />SCJD
has been used in the past by others succesfully to pass the SJCD
SCJP, SCJD, SCWCD, OCPJBCD
Is this the real life? Is this just fantasy? Is this a tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|