Is ServletContext.setAttribute() atomic?
If my servlet make just a call to ServletContext.setAttribute() (or session.setAttribute() ), is it a must to synchronize this single call? Assuming any two threads could execute the setAttribute() call simultaneously.
This question come into my mine because I realize that even setting primitive double type isn't guaranteed to be done atomically by the JVM spec. Therefore, if 2 threads are modifying the same double variable at the same time, problems could happen - one thread's data get PARTIALLY overwritten by other thread..
Now, if 2 threads simultaneously calling setAttribute() on ServletContext, would changes of one thread overwrite PARTIALLY the changes made by the other? If the call only contain atomic write operations, then one operation can completely overwrite the other one and we got no problem. But if setAttribute() contains some non-atomic operations the partial update problem could happen.

