my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S 2.3.1 locking in non-netwok mode? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S 2.3.1 locking in non-netwok mode?" Watch "B&S 2.3.1 locking in non-netwok mode?" New topic
Author

B&S 2.3.1 locking in non-netwok mode?

Michael Donley
Greenhorn

Joined: Aug 26, 2008
Posts: 5
Hello everybody!

I have just got the assignment and found this nice forum with all you discussions regarding the SJCD exam! Nice that all of you are assisting each other! Hope someone can help me with my questions.

The first thing that crossed my mind was locking in non-network mode? Can one assume that 1, and only, 1 client is assessing the DB file when they run in the same WM (i.e. no networking)? If that�s the case, no locking should be used when reading and updating the DB file, right?

Thanks in advace!
TM
Jethro Borsje
Ranch Hand

Joined: Jul 22, 2008
Posts: 100
I have the 2.2.1 version of the B&S assignment, this assignment says the following on "Locking":
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. 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. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.


However, locking the data should not be a problem when you use the client / server in one JVM at the same time.


SCJP, SCJD
Michael Donley
Greenhorn

Joined: Aug 26, 2008
Posts: 5
Thanks Jethro for your answer!

I got the same description as you, but I still don�t get it. I think the sentence is misleading

"...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..."

What does it mean?

I mean "... at MOST one program is accessing...", what does that mean? MOST???

My plan was to ignore any locking mechanism when running in "non-network mode". I.e. The Gui is accessing some service methods which are not doing any locking (the service methods access the DBMain). I will also have service methods which accessing the DBMain in network mode but these will use locking.

So, can my system access the db methods (in DBMain) via my nonlocking service methods? That is, can I assume the non-network mode consists of only 1 client?

Thanks in advance!
TM
Jethro Borsje
Ranch Hand

Joined: Jul 22, 2008
Posts: 100
I think you can assume such a thing, but why would you want to do that? I mean: you might as well let the client use the "normal" locking code, because this should work fine. Locking should have no consequences when you are using just one client at a time.
Michael Donley
Greenhorn

Joined: Aug 26, 2008
Posts: 5
I guess your right. The reason why I asked was because I did not want use locking mechanism when there is no need for it. I thought this approach is cleaner... I mean why use locking when there is no need for it... But just as you said, it does not do any harm so the same code can be used....

Thanks for you answer!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

"The Man",

You apparently missed our Naming Policy on the way in. Please read that page, then follow the link there to change your screen name.

Thanks


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Michael Donley
Greenhorn

Joined: Aug 26, 2008
Posts: 5
fred rosenberger: Im sorry for my name, I have changed it now...
Alenkhe David
Greenhorn

Joined: Jul 31, 2008
Posts: 20
So is locking in non-network mode a most? I, mean its only one JVM.


Jesus Regins..
Jethro Borsje
Ranch Hand

Joined: Jul 22, 2008
Posts: 100
It is not a must, but I think it is bad practice to try to avoid the locking as it should be part of you data access layer. This data access layer should be used by your client, regardless of networked or non-networked mode.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: B&S 2.3.1 locking in non-netwok mode?
 
Similar Threads
non-networked mode and locking
Waiting for my exam...
how does the program start?
Database Locks
NX: Client side lock vs Server side lock