I am supporting a web application written by someone else and I am seeing some funny behavior. The application uses struts, spring mvc, and tomcat as the app server.
The web app is displayed in a frame by some third party and accessed through a link.
When the link is clicked two requests are sent to tomcat on two threads. One thread is supposed to authenticate the user and initialize the data. The other thread uses the initialized data to render the screen.
Problem:
Sometimes the dependent thread kicks off first resulting in an error being displayed on the screen. But because the initialization thread is still processing and does complete after dependent thread the results are returned to the user and the appropriate data is displayed on the screen. The problem is the error displaying while the initialization thread is running.
Question:
Is this behavior something inherent in struts or Spring MVC? I am not seeing anything in the application that is causing this behavior.
I would personally like to just kick off one thread and do the initialization and display in a synchronous call.
Thanks in advance for any help.
This is called a race condition. Very common when you start dealing with threads. It has nothing to do with what you are doing, but in the quite random behavior of running code and whichever way the threads decide to fire off, that’s what they do.