I think that I am fortunate in that I have the URLyBird project, and no cookies are passed into the lock and unlock calls;
where the above is symbolic, psuedo-code which sort of looks like Java. You are not referencing Data from the client directly, that is; but you only have an object reference to the Server object which you have built.
Now, if the above is true, you must only have one instance of Data for the physical Random Access File. This is carried out simply by the Server making sure it doesn't instantiate more than one Data.
If you really are instantiating more than one Data object, then even if the methods are synchronized, you are still battering and "destroying" your database random access file.
I'v read a lot of your comments in other threads and get a lot of benefits from it, thank you, you are one of my teachers here.
Leo (about the notifyAll() in lock()):
Because others do it, before I understand this thread, I just do it.
From design, I agree you. But in my assignment(URLyBird 1.3.1), no requirement of this. I think I use WeakHashMap as the locked container and Data.this as the key of the item, it cann't be duplicated, so I may not take care of this. Only one thing can take place, when one Data instance(client) locked a record that number is 4, after a while, he locked the record 5, then in the locked container only store he locked this record, the record 4 is covered. What you think about it ? Pls write your mind.
Sorry, I don't understand what you mean, could you detail a bit on it and the code below the statement ?
This is my new ugly code.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Mmh... You'd better understand that thread before making a choice. A notifyAll() call cannot be justified by a "I did it just in case".
But if you do, the minimum is to make sure that your implementation ensures (and is consistent with) your own design decisions.
....multiple tables...
After read the thread carefully, I understand and decide not to use it. But I have a question, if I use notifyAll() in lock() method could make some problem ??
...multiple tables...
I'v seen this word in other thread, but I think I don't support it, so I didn't read it. Did you implements it? How you do?
Perfect !!! How beautiful code !
I got your mail, but I cannot read the attachment . Please resend it, but with a simple .java (or even .txt) file attached.
I think "yes", but all people don't think so. I just entered in discussion with Max about it to clear things up, and I'll post the results here or in a new thread within the next couple of days.
....at last, I select Data.this--recNo as it, whether this cause the one_lock_on_one_table_per_client scheme ?
....at last, I select Data.this--recNo as it, whether this cause the one_lock_on_one_table_per_client scheme ?
You'v not answer this question yet![]()
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|