What I don't understand is this. So I have this static method. It saves a string of data to the filesystem. It creates a FileWriter, then it saves it, then it closes it.
So if it's Static, that means there's only ever 1 copy of this code in memory to serve all requests. In my servlets, I call this method at the end, to save my file that I work on in the servlet.
My question is this, with multiple users calling this method, and different servlets running it possibly at the same time, what's to stop data from mixing? If there's only one version of it running, is it a bottleneck?
So if it's Static, that means there's only ever 1 copy of this code in memory to serve all requests.
The bytecodes comprising both instance and static methods will be loaded only once per loaded class.
If several threads call an unsynchronized method, they will be able to execute it concurrently. Because there is no shared data that might be modified by a thread in an inconvenient moment for another thread, the only source of problem might be the attempt of writing to the same file. But you you said it was not the case.
SCJP2. Please Indent your code using UBB Code
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
subject: To declare Syncronized or Not, always the question!