Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Rong Chen

Ranch Hand
+ Follow
since Aug 07, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rong Chen

Jerry,
First, I didn't assume that synchronizing access to all code that modifies the db is sufficient. Second, I don't like the idea of a server trusting clients to behave appropriately either. That's way I implemented lock()/unlock() at server side. The rmi interface I defined for client is an all-in-one method: seserveSeat(), inside it is sequential lock(), doBooking(), unlock(). So the client would never call lock/unlock directly, the server takes care of it.
Even though, I didn't need any client identifier. I will just follow the specs of my assignment - "Record locking must be implemented using the methods public void lock(int) and public void unlock(int)". The only disadvantage of this design is that I can't implement queue(FIFO) for each locker. But, after all, I don't want to introduce more complexities at the same time violating Sun's specs.
>I'm not sure what you mean when you say "let the jvm do synchronization for each locker".
: I have my own locker class for every record and rely on wait() and notify().
>Are you thinking about grabbing a synchronization lock in lock() and keeping it until unlock()? How would that work? The sync lock would be relinquished when the lock() method returns.
: Yes, it's exactly what I am doing and it works. The sync monitor will be relinquished when the lock() method returns of course, so other clients can have chance to enter lock() block and then be blocked or not according to the status of the locker.
>Also remember that, at least in an RMI server, you can't depend on all requests from a single client being handled in the same thread. What if RMI placed the client's modify() call in a different thread than its lock() call?
: As I said before, I put lock(), doBooking(), unlock() in the same RMI method and implemented on server side, the problem you mentioned would never appear.
Cheers!
/Rong
queue seems more attractive since in normal object synchrinization, notify() doesnt hornor the coming sequence of locker requeust threads. in bad case, it can happen like this, thread A first grabs the locker, thread B comes aftetr A, so it has to wait, thread C comes later than B but possible get locker after A release locker and call notify(), then Thread D comes, after C finish its business, it calls notify(), guess what, D could get notified but not B, poor B..
tell me if i am wrong about this..
/rong
jerry,
i have seen a lot of discussion about identifier of each client concerning the lock\unlock problem. i don't understand why you guys really need an identifier for specific client? isn't it clearly written in the Sun's requirement that you must implement lock(), unlock() only using recordNumber as parameter and void as return value?
my design is let the jvm do synchrinization for each locker so that you dont need any identifier for clients. it seems that we might need an identifer for each client if we are going to implement a queue for each locker. in this case, we have to use something to distinguish clients to achieve the goal that first come, first serve. the queue seems more attractive than normal object synchrinization, however if it's impossible to implement a queue without modifying the signature of lock(), unlock(), i certainly will give up a queue design for each locker.
what do you think jerry? can you clarify why you have to use client's unique identification (i dont think it really does matter which side you will implement the lock, unlock functionality.)
cheers!
/rong
i am working on fbn assignment and now in stockholm, glad to meet you guys and share understanding of the assignment..
tel at work: 8-7287344
mobile: 073-9876253
rong
hi,
i know at least two: the famous R&H book(has dedicated SCJD section) and widely used Core Java Volume 2.
besides, you have sun's java tutorial on the net and a lot of links...
rong
yes, i also found these words in Exam Cram, but i simple don't think they are reserved in java.
rong
hi,
i just passed SCJP last week, and am preparing SCJD now, thank you for your info.
rong
hi guys,
thank you all!
rong
hi guys,
don't think static method can't be overriden, it can be hidden by implementation in subclass instead. either, i don't get the point why one would bother to write the entry of an application twice. but one thing for sure is that final doesn't appear in the recommended form of main() as an entry of an application anywhere. so, just forget it.
regards
rong
hi Kishan,
well done! i also cleared it today.
regards
rong
hi everyone,
first of all, let me thank JavaRanch, thank Paul, moderators and all your fellow JavaRanchers! without JavaRanch i couldn't make it happen so soon(i loosely start to learn java in july, and began intensively reading from 5th of Sept.)
my background is i graduated from medical medical and in the second year of PhD program of medical informatics now, but also have at least ten years of C/C++ programming experience. i think this is really helpful in my java learning.
black friday? yes it is. friday and 13th together means bad luck?! first the test center made wrong spelling of my name, and during the 90 minutes, the computer crashed down twice!! oerwise, i probably can clear it with better score... so now i get a score report of 89% but my name is not on it, perhaps it's better then a failed report with my right name on it, right?
about the exam itself, it's much easier than i expected.. questions are very clear as others said before, codes are constructed neatly, only few of them reach 30 lines. i met three fill-in textfield questions. some of questions about threads(there are 7) are difficult, i lost two among them(and i still can't figure out why).
two or three intger value in flowcontrol condition, a lot of String and StringBuffer manipulation.. 2 or 3 IO, they are basic. more than 5 about overriding and overloading.
in my exam, there are only around half questions with more than one answers, and basicly they are easy to answer since you know the number of right answer! there is not any select-right-answer-from-two-choice like ture or false like you will meet in mock exams. there are also two questions with more than six choices in the exam(also easy).
90 minutes is enough, even in my case(computer crashed twice, i run to the office and ask someone to help me, reboot, connect, back to right number and relax coz all answers are still there, but anxious anyway..) i finished all 59 in 65 mins and managed to review all of them once before time ended.
about mocks, i think they are certainly helpful if you use them as learning tool. they tell you every trick/traps(some might not appear in real exam likily) in the exams, but not as socring tools. some time, they will only defeat your confidence. to be frank, i only socred 70% in marcus green's #3 exam according to its original answers in last day, i didn't even bother to find right answer for them since i am sure i know the knowledge points the auther want to test me, but because of unclear words of qestions or even wrong composing of questions/answers i got such low score. but still i achieved 94% in R&H's tester program in last day, which is well constructed and quite similar to the real test.
books used: 1.think in java2 in first phase, it's nice book for introduction of java to C/C++ programmers and it's free to download at http://www.mindview.net; 2. Mughal's programmer guide to java certification, this book is excellent! greatly recommended!! 3. JLS 2nd, stands for java language specification the second version(warning: there are certain differences between 1st and 2nd JLS, so chose the right one when prepare for SCJP2 exam), yes, yes, yes, it's our ultimate weapon against the exam!! check it if you have any doubts of java, however it's hard to read i didn't finish all the chapters of it myself; 4. the java API, go through import classes in lang/io/awt/util packages and know the names of their fields and methods
let me think what else? oh, before i sign off, two things i want to say: 1. don't miss new javacertfaq in javaranch, it's truly informative, especially the common tricks/traps in the exam part, i like it very much! link: http://www.javaranch.com/certfaq.html; 2. support javaranch by merely click the cute banner in the top of the window, can't see it? use scrollbar! ahh, here it is, i click, i click, click, click...
rong chen, scjp
hi,
i am going to take it next week probably, can anyone share experience of new version of SCJP exam?
thanks in advance
rong chen
just find something in the java bible, jls, which we can rely on, is says:
9.1.1.1 abstract Interfaces
Every interface is implicitly abstract. This modifier is obsolete and should not be used in new programs.
rong chen
>if(amethod())
the return type of amethod() other than boolean must result in compiler error... think so.
sample code like this:
boolean compare(int a, int b){
if(a >= b)
return true;
else
return false;
}
// then it will compile like this
if(compare(3, 2))
System.out.println("a >= b");
else
System.out.println("a < b");
actually, there are lot of methods return boolean value in java API, check them out...
rong chen
[This message has been edited by Rong Chen (edited October 06, 2000).]
[This message has been edited by Rong Chen (edited October 06, 2000).]
i played with it in the last few days (including yesterday and this morning) without any problem.
try again, buddy.