• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Zonglin Li
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!
 
Zhongbo Li
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one database can get lock.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!