Quartz source analysis-execution engine and threading model

Source: Internet
Author: User

Title:quartz Source analysis-execution engine and threading model
date:2017-09-09 23:14:48
Categories:quartz
Tags: [quartz, source analysis]
---
---
[TOC]

Software version: quartz-2.2.3 sequence

The previous article introduced the Quartz start-up process, this article mainly introduces quartz threading model, it is well known that Quartz did not use the timer to complete the scheduled task, but through the thread to complete. To simplify your understanding of the Quartz threading model, take it easy.

Class name
Simplethreadpool
Workthread
Quartzschedulethread
Jobrunshell
Speaking from the configuration


From the above configuration file can be seen quartz configured a thread pool, the implementation name of Simplethreadpool, this thread pool function is what, I write comments in the code. the foreman in Simplethreadpool--quartz.


The above is the member variable of this class, from the member variables above, it can be seen that the thread pool with LinkedList storage to execute all job workers (worker), to manage all workers, then we call Simplethreadpool as foreman, If the boss wants to assign a job, he will find the boss and the foreman is looking for the idle worker to handle the work.
What's the foreman's interface to the boss, keep looking down?

The above Runinthread is the foreman to the boss to provide the external interface, runnable is the boss of the work arranged, the process is this:

the workers in the Workerthread--quartz

Introducing the foreman, and then introducing the workmen, the foreman, by invoking the Work.run method, the workers began to work.
Open the code, please.


The foreman handed the task to the worker, the worker thread was blocked, and when Runnable was assigned, the worker thread was awakened. The flowchart is as follows:
the boss inside the Quartzschedulerthread--quartz

Quartzschedulerthread is the class that is really responsible for time scheduling in quartz, and the run method of this thread is also the outermost loop. Mainly responsible for task triggering, work Packaging, Task batch control, this method is the most difficult method of this chapter, look at the main loop

Boss threading involves a lot of detail, look at the flowchart

The above process is about the same, it is recommended to look at the code to see the process, to help understand. Threading Model Diagram

A diagram of the

The above is their own opinion, if there are mistakes, please advise, common improvement. Reference Document Quartz Official document Http://www.quartz-scheduler.org/documentation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.