Here\'s the scenario: I have a multi threaded java web application which is running inside a servlet container. The application is deployed multiple times inside the servlet
If you only need to write the file rarely, how about writing the file under a temporary name and then using rename to make it "visible" to the readers?
This only works reliably with Unix file systems, though. On Windows, you will need to handle the case that some process has the file open (for reading). In this case, the rename will fail. Just try again until the rename succeeds.
I suggest to test this thoroughly because you might run into congestion: There are so many read requests that the writer task can't replace the file for a long time.
If that is the case, make the readers check for the temporary file and wait a few moments with the next read until the file vanishes.