• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Problem in Andrew's Denny DVD - CleanExit.java?  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone:
I think there is a mistake in Andrew's DVD example. Inside the book, it uses 'CleanExit.java' to handle the server shut down. When the user shut down the server, 'CleanExit' will called by the JVM and do some clean up.

Code:
/**
* This method will be executed by the JVM when the application is shutdown.
* It ensures that the database is in a clean state for shutdown (that is,
* there are no outstanding writes occuring).
*/
public void run() {
log.info("Ensuring a clean shutdown");
try {
DvdDatabase database = new DvdDatabase(dbLocation);
database.setDatabaseLocked(true);
} catch (IOException e) {
log.log(Level.SEVERE, "Failed to lock database before exiting", e);
}
}

I assume this is wrong. Because it creates a new database and locks the new database. The real database which has been used by the clients has not been locked for clean up.

Could anyone address please!

Thank you very much!
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one database can get lock.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!