I know I've been posting like crazy here and I thank you for your patience. Im running tight on time. I need to complete the assignment by December 25th and I have yet to submit my code. As a point of interest, how long do Oracle take before they indicate whether or not you need to sit the essay?
Back to my question, what is the standard way to handle deletion of a record?
If this is so, how can something thats been deleted be unlocked?
Well, in my case, I had a Map<Integer, Long> where I keep track of what records are locked. The key is the record number, and the value is the id of the client that owns the lock. I also had a Map<Integer, Room> that represented the database records. After deleting a record, its corresponding entry is removed from the Map that represents the database records. And to unlock a record, its corresponding entry is simply removed from the Map that keeps track of the locked records, so there is not problem if it was already deleted.
So everything is handled virtually, in memory. When the application finishes, the Map that represents the database records is flushed to the .db file.
Regarding the essay, when I took this certification, we had to take the essay after submitting the assignment. We just got a voucher for that and scheduled it online in a Prometric center. I think you still have to do it nowadays. For more information, please take a look here.
Thanks for the reply. My difficulty now is, what to do with the threads that are waiting on a record that just got deleted? From your scenario, I think you have come across this issue too.
For example, thread 5 is waiting to lock record 26.
thread 4 deletes record 26.
thread 5 wakes up and checks if the record still exists in
. If not, it throws a record not found exception.
Map<Integer, Long> where I keep track of what records are locked
When I do the above, I see IllegalMonitorExceptions and deadlock sometimes occurrs.
EDIT:The thing is, when I run your test class with updateRandom,Update1,Find and Create, everything runs smoothly. If I run the delete threads too, thats when I see IllegalMonitorExceptions and deadlock.
IllegalMonitorStateException typically happens when you invoke wait/notify method without holding a lock on that object. Is this the case in your code?
Also, check if you are releasing the locks in 'finally' block. If not done, then it is very typical scenario in which a lock is obtained, and due to some exception, it is never released. This may further lead to deadlock.
Roel De Nijs wrote:I see you where in good hands when I was enjoying some sun & sea, but now I'm back
As far as I can tell 99% of the hands around here are good.
I hope your holiday went well. You find me in the middle of doing my choices.txt file. I've been reading through the past pages on this site for ideas of what to include/not to include. I came across your good self's list of contents. Im wondering how high/low level to get?
Do I keept it as a design pattern level or do I go down low and discuss why I used a LinkedHashMap over a HashMap?
Glen Iris wrote:I hope your holiday went well.
Yes, although the weather was in the 1st half a bit less than expected, I really enjoyed it and had a great time
Glen Iris wrote:Do I keept it as a design pattern level or do I go down low and discuss why I used a LinkedHashMap over a HashMap?
The choices.txt (and the essay exam) are designed to make "sure" that you developed the assignment yourself and not some java whizz kid next door. So the more detailed your information is, the better of course. I mentioned class names, method names and data member names. Both in the decisions document as on the essay exam. So i would opt for low level, of course only appropriate parts. It's useless to discuss the need of every variable and why you chose that particular type.
Roel De Nijs wrote:Yes, although the weather was in the 1st half a bit less than expected, I really enjoyed it and had a great time
At least it ended on a high and I bet even the first half was better than Belgium (and Ireland) at this time of year anyway!
Im running at about 3800 words. Do you remember roughly your word count?
Since the course requirement the amount of participants for this exam has dropped extensively. I submitted somewhere in June and got my result in november. During that time there were a lot of developers who wanted to finish this exam before the course requirement date (and the transition to Oracle and/or PearsonVue was messy at that time).
Next weekend you have your results....at least that would be my wild guess. Until that time...relax and have a beer.
lol roel was faster
But based on this link you have to complete a form which Oracle uses to verify you followed one of the required courses. When you decide to follow one, is completely up to you.
Glen Iris wrote:Thanks for the reply. My difficulty now is, what to do with the threads that are waiting on a record that just got deleted?
just to give additional value to this topic, I share how I solved the same issue : http://www.coderanch.com/t/584411/java-developer-SCJD/certification/notify
I remember that it was very hard for me to detect why some deadlocks still occured at the end of my development. The issue is related to some threads waiting for a record that is deleted by the one which owned the lock. What I have done is to call notifyAll() in my delete-method for all threads which are waiting for the lock (1 lock per record is possible in my solution). Once the thread has been awaken, it just raise a RNFE because the record is not in the memory cache anymore.