jesal dosa wrote:So I assume if I just have a finally() method in the data class which closes the file
Nicholas Cheung wrote:
In addition, you may override the protected function finalize() in order to release any resources held by the system.
But, whether the resource is released is NOT assured.
K. Tsang wrote:In my design, I have a clientCount, I would simply check this variable during/before shutdown.
K. Tsang wrote:the client is pretty simple. In my remote interface I declared 2 methods connect and disconnect to print the client IP connected/disconnected on some date at some time when clients instantiate the Data class or service.
K. Tsang wrote:This is why I'm not sure how Jesal is able to directly close the RandomAccessFile in the Data class without some sort of method in the service layer.
Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.add(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Paul Balm wrote:Note by the way, that the functionality I suggested (server obtains DB lock, etc.) can not be in a JVM shutdown hook. When you enter the server shutdown hook, all threads have already received an InterruptedException (I think -- might also be a ThreadDeath or something). If one of the threads was halfway writing a record, your data will be corrupted.
Paul Balm wrote:Hi K,
The part about threads being interrupted halfway a write-operation is the point of doing a neat shutdown though. If you don't think that is likely to happen, why do you need to be careful with the shutdown of your server?
Paul Balm wrote:Your results contradict what I was saying of course...
Paul Balm wrote:Unless your implementation is different from what I understood in some important way.
Paul Balm wrote:I'll do the same test with my application and I'll post the results here.