This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Production-Ready Serverless (Operational Best Practices) and have Yan Cui on-line!
See this thread for details.
Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Denny's DVD setDatabaseLocked method  RSS feed

 
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am preparaing for the OCMJD exam and I read Andrew Monkhouse and Terry Camerlengo's book (SCJD Exam with J2SE 5 platform second edition) . I read and run their source code and I have a few questions that I'd like you to answer please. Source code follows.

1- why do they call getDvdList(true); in DvdFileAccess constructor if (database == null)? I mean if (database == null), then the physical database is empty, so we cannot get any DVD list basically. Therefore, we cannot populate recordNumbers (i.e Contains an index for our primary key (UPC number) to file location.) either. This is so confusing that I feel like I must be missing something. Any thoughts?

2- I tested the DvdDatabase setDatabaseLocked(true) method (which should lock the database) in my Main method as follows.



Well I don't understand why I was able to add a second DVD after locking the database. I was expecting an exception. How can change the source code to really lock the database and avoid this.

3- If I create 3 DvdDatabase clients in my main method, I will never be able to test the ReadWriteLock mechanism because they are not Thread classes right? so how do I test the locking mechanism?

4- I am not comfortable with ReadWriteLock, Lock,Condition classes ? Do we have to use those at the professional level or can we stick with the basics (i.e Threads, synchronized methods, wait , sleep , notifyAll) and do exactly the same thing and meet the professional standard?

Below the source code for the relevant classes :








Thanks for your help.

Sincerely,

borkev
 
What's brown and sticky? ... a stick. Or a tiny ad.
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!