Before getting Java EE-specific, it is important to step back a moment and understand the implications of concurrency on the programming model.
Thread data and consistency
Concurrent data access
When a single thread accesses data, then the access is always thread-safe, and it is not possible for a thread to mutate data while another one is reading it. When you increase the number of threads and multiple threads can access the same data structure instances, it is possible for a thread to read the data that's currently being modified, or for two concurrent modifications to happen, leading to an inconsistent result.
Here is a schema representing this issue with two threads. Keep in mind that a Java EE server often handles...