I am wondering at what areas of your code spawned their own threads explicitly? (I am sorry this is such a elementary question, but I just want to know how to get the best performance using multi-threading). Currently, the only place I programmatically spawn a new thread in only one place which is every half hour to do some writing and reading of the cached data (of course this is besides my main threads). I know RMI does some multi-threading under the hood and when networked there will be some concurrency. Did any of you guys spawn new threads in your code (besides the main methods). Once again I know this is a subjective and rather daft question to ask but I guess I am just an insecure bugger
As a developer it's always nice to write some code that performs well. However, for this assignment I would't care that much, because the assignment says that a less performant design which is understandable for junior developers is preferred over a more complex, high performant one.
I read you perform some reading/writing of cached data every 30 minutes. That has advantages, because the possibility of data loss is reduced this way. Again, this is not a must requirement and it will complicate your code.
I launch an extra Thread when the application closes. A shutdown hook thread will write my cached data back to the .db file. This approach is more risky (than yours) due to the possibility of data loss, but it keeps my code more simple.
I guess our SCJD guru Roel will tell you this: KISS
I completely agree with Dennis. He's spot-on and I did exactly the same (just 1 extra thread as a shutdown hook).
And about your writing-cached-data-thread-every-30-minutes: nice solution to limit data loss to a minimum. I documented such a solution in my choices.txt as a way to solve the issue of possible data loss (one of the drawbacks of using a data cache). I didn't add such an implementation, because it was not a must requirement and makes your solution more complex, which violates the KISS principle (here it is ) of my application
Dennis Grimbergen wrote:I guess our SCJD guru Roel will tell you this: KISS
Just wondering how there could be data loss? If I'm correct in understanding the general setup, the server reads the file into a cache at start up and writes back at shutdown. Is it if you have multiple servers? Do people test their solution with multiple servers, or just multiple clients?
Thank you partners,
I was writing directly to the disk in my project, so I did not have to sync the cache from time to time. However I did use the shutdown hook as well, and other than that no manual thread spawning, RMI took care of all at the end of a day, socket solution would be different.
Thank you partners,
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com