Hello, my dear Ranchers,
Currently I am doing nothing in my project to prevent data corruption arising from the server closing down with networked clients still attached. I have a server GUI, so when the close option is taken, I start the close down operation.
My first question is, should I take action by specifying a ShutdownHook or just continue the close down operation in the current
thread? I assume that a ShutdownHook caters for situations in which an application ends in a controlled or uncontrolled manner, so my instinct is to use the Hook.
Secondly, I am thinking of locking the database as part of the shutdown procedure. The idea is that by the time I have locked all the records, I can be sure that no client is in the middle of an update. My concern is whether this processing, if running in a separate thread as part of the hook, will finish before the connection exception is issued to the client. Will a hook help? That is, will it ensure the lock process completes before the network goes down?
Any thoughts on this will be appreciated.
Simon