Is the java background receiving request processing single-threaded?

the foreground uses ajax to request the backend. A simple operation, such as submitting the form, calls another ajax request to refresh the list after the form is successfully returned. After receiving the form data, my backend saves the form data into the database, and then returns the success. After the code returned by reponse, continue to process the business logic, so that when the backend continues to process the business logic, the foreground has been successfully returned. Then the foreground continues to initiate a request to refresh the form, but finds that the background must wait until the previous request to submit the form has processed all the business code before responding to the request to refresh the form. It feels like a thread is processing the request serially. As far as I understand it, a request request should take a new thread from the thread pool to process the request to the corresponding whole process, and each request should be independent. Why is there such a situation in which a single thread processes multiple requests at the same time? Is it the reason why it was launched on the same page? Because as long as you open another page, there will be no problem, and the blocking of the current page will not affect another page

Mar.16,2021

the backend must be multithreaded. I think when your backend response is set, it is not really returned to the foreground, and the response will not be sent to the foreground until your business logic is processed, so it gives you the illusion of single threading.


in this way, when the business logic continues to be processed in the background, the foreground has been successfully returned
. I don't understand. Ajax has gone to the backend to request, but there is no business in the backend that has not been processed. How did the foreground ajax get the response result first?

and I think your thinking point is put directly in the background, have you ever considered the situation of ajax nesting (also pay attention to ajax's Synchronize asynchronism), this has no code and I don't know, I can only give a suggestion.

as for the last point, I remember thinking about this question when I first came into contact with spring. This is related to scope. You can write a demo,. When I was writing the demo test, I set a member variable, and every time the request came, I found that the PP, result was always accumulated by default. (I'm not sure about this result. I wrote it a long time ago. You can try it yourself.)

Menu