I have a global variable in a servlet class. What will happen to this global variable if two requests hit on the same time?

Renato Michielin

What will happen is an unforeseeable event.
The best way to establish a default occurrence (the servlet handles a request at a time) is to synchronize the access to the global variable or alternatively to create a servlet that implements the SingleThreadModel interface.

[See How do I ensure that my servlet is thread-safe? for more information. Note also that using SingleThreadModel may not work, if other servlets/classes access the global (static) variable as well. -Alex]