Kang Wang

Greenhorn
+ Follow
since Feb 03, 2003
Merit badge: grant badges
For More
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 Kang Wang

Hi Daniel,

You don't have to synchronize this get method. I didn't and I didn't lose marks for it. It is possible that a second thread enters the method and changes the value of n before the first thread calls databaseColumns.get(n); However, I personally don't think the marker will look for this.

If you want to be safe, perhaps you can try Collections.synchronizedList(List), which returns a thread-safe List based on the argument List.

Hope this helps.

Kang Wang
SCJP, SCWCD, SCJD
Hi,

I would say some practical experience definitely helps you pass the assignment. However, it's not necessary in every case. If you have done a few school assignments/projects in Java, you should be ready for SCJD. It would be even better if you have learned Model-View-Controller design patter in class.

I am a 4th-year university student and just passed SCJD. My experience tells me that as long as someone is famaliar with Java basics, this person should be able to pick up new knowledge and skills quickly. To help you get started, I suggest studying synchronization and sockets concepts, not just how to do them in Java, but the general concepts. Doing SCJD assignment is a rewarding experience. What you learn from the process will be your assets forever. If you are not too busy with school, pass it as early as possible.

Hope this helps.

Kang Wang
SCJP, SCWCD, SCJD
Congrats dude!

To Jack, It took them a little bit longer than 6 weeks to release my score.
18 years ago
Thanks guys.

For Tong, are you .NET certifications issued by MS? How useful do you think they are?
18 years ago
Hi Guys,

After waiting for more than 6 weeks, I finally got my results: 331. Its not the best mark that I hoped for, but I passed the damn assignment. Great thanks to ya ranchers!

General Considerations (maximum = 100): 89
Documentation (maximum = 70): 70
O-O Design (maximum = 30): 24
GUI (maximum = 40): 24
Locking (maximum = 80): 44
Data store (maximum = 40): 40
Network server (maximum = 40): 40
18 years ago
Hi,

Sorry. I just searched this forum and found two old posts that discuss this issue in great depth.

In case anyone else is wondering the same thing, check out:
post1
and
post2
Hi guys,

I'm not entirely sure how to interpret the following line from the specs:

"It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user."

The phrase "and/or" is puzzling me. If the use enters both a name and a location, am I supposed to fetch all records that match both or either one? Or am I supposed to provide the option to let user choose which relation?

Can someone kindly advise on this?

Thanks
Kang
I have resovled this problem. I didn't create a server socket that listens on the specified port. Learning is always fun.
Thanks a lot Ed.

I have another question, however, in regards to locking in URLyBird 1.2.2. I am not sure what is minimally required for the locking scheme. Here is my understanding of locking and please correct me if I'm wrong.

1. If some one is reading a record, no writes can be made to it, but writes can be made to other records.

2. If a write is being made to a record, no one can read it or write to it, but other records can be read or updated/deleted.

3. Concurrent reads on any record are allowed.

Are these points what the graders are looking for in the solution?

Thanks
Wei-ju and Ed:

Thanks very very very much! Awesome clarification.

Kang
Hi All,

The posts in this forum are very enlightening. I have been thinking about the locking issue the whole morning today. I would like to share my thoughts and hope that you guys can advise on them.

If there is only one Data object on the server side processing all database requests, then the readRecord(long recNo) method must be synchronized. Otherwise, the local variable recNo may be changed by another client before the method completes. That is, if the server spawns multiple threads to handle multiple concurrent client requests, and these threads call methods on the same Data object, even reads need to be synchronized. This approach is not the most efficient.

Similarly, since createRecord(String[] data) does not require a lock cookie, it's possible that client 1 is trying to read while client 2 tries to create a new record. This scenario also requires readRecord(long recNo) be synchronized.

Now, suppose the server spawns a new thread for each client request, and each such thread creates a new Data object to work with the database. My understanding of synchronization is that each thread will have its own separate copy of a Data object on its stack. Therefore, keyword synchronized will not work on non-static methods. In other words, thread A calling a synchronized method doesn't prevent thread B from acquiring a lock on its Data object. Thus, both threads may modify the database at the same time.

I realized that the locking that should be achieved in this assignment is data protection on the database file. Concurrent reads should be allowed while concurrent writes should not be allowed. If there are reads happening, write requests give up CPU and wait, and vice versa.

My pesuedo solutions is that each client request is handled by a separate thread with its own Data object, so that concurrent reads are possible. As for writes, we can do locking on a static variable. A quick way to do this is using ReentrantReadWriteLock class in JDK1.5.

Just some thoughts. Please don't mind me if this post doesn't make much sense. I just started my assignment 2 days ago, still in the process of analyzing the requirements. Hope you guys can correct me if I'm wrong and lead me to better ideas.

Thanks
Kang
Hi All,

Hope you guys are doing ok on this assignment.

The instruction says the following:

"the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used"

- Is the user allowed to choose a different db file at any time? What if there are more than one db file on the server and the clients don't select the same file?

Also, what's the difference between server mode and standalone mode?

Thanks
Kang