This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I recently developed a thread whose purpose is to run maintenance on database tables, send out emails, etc. When this system was deployed to the server, I noticed that the server had two servlet containers running in parallel on the same machine. I assume this is something our server team put in place to help with load balancing, etc. (This second VM was on the same machine, not a fail-over machine). As a result, the thread was actually run in both containers. I had added a System attribute to prevent another Thread from running if a hot re-deploy was attempted, and it stops another thread from running in the same VM. But, I noticed that the second servet container also runs the thread. Am I to assume that the two servlet containers do not share System properties because they are running in separate VMs. Also, should I assume that if we were to have a fail-over machine, the Thread would have executed in both machines, so I would have a similar problem? To solve this, we created a persistent data source that holds the unique ID of the last Thread that modified the source, so it will be the only one to run. Any other thoughts on how I could have handled this? Thanks for your inputs!