• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Denny's DVD setDatabaseLocked method

 
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic