[Spring6 source code・MVC] request processing flow source code analysis

In the previous article "[Spring6 Source Code·MVC] Initialize the registry and complete the mapping relationship between url and controller", we know that when the IOC container is loaded, the HashMap of the registry is initialized, and the request path and corresponding method are stored in this HashMap. When we make a request, we will get the corresponding method through this registry.

When the SpringBoot project starts, a thread is loaded:

insert image description here
Step into the run method:

insert image description here
Step into the run method:

当前这个类是Worker: The Class Worker primarily maintains the interrupt control state of the thread running the task, among other minor bookkeeping. This class opportunistically extends AbstractQueuedSyncer to simplify acquiring and releasing locks around each task execution. This prevents interrupts that are designed to wake up worker threads waiting for tasks rather than interrupt running tasks. We implemented a simple non-reentrant mutex instead of using ReentrantLock because we don't want worker tasks to be able to reacquire the lock when calling pool control methods like setCorePoolSize. Also, to suppress interrupts before the thread actually starts running tasks, we initialize the lock state to a negative value and clear it on startup (in runWorker).

This run method is mainly to start the main running loop, so as to take out the task execution from the queue.

Guess you like

Origin blog.csdn.net/CSDN_SAVIOR/article/details/128969268