1, quartz source of the bottom, is to use wait, notifyall to deal with. So you have to understand the wait and notify before you know it.
First come to an interview frequently asked Questions: Wait and sleep contrast, for both, in short sleep is thread (thread) static method, thread blocking does not release the acquired lock, waits is the method of object, also block the thread, but also release the lock. A wait thread is awakened with the following scenario: A, another thread calls the object's notify/all;b, wait timeout, C, and calls the interrupted method.
The wait, sleep ratio code is as follows:
public class Waittest implements Runnable {int number = 10; public void FirstMethod () throws Exception {System.out.println ("***first begin**" +thread.currentthread (). GetName (
));
Synchronized (this) {System.out.println ("***first has get lock**");
Number = 100;
SYSTEM.OUT.PRINTLN (number);
Thread.Sleep (50000);
This.notify (); } public void Secondmethod () throws Exception {System.out.println ("***second begin**" +thread.currentt
Hread (). GetName ());
Synchronized (this) {System.out.println ("***second has get lock**");
/** * (rest 2S, blocking thread) to verify that the current thread object's machine lock is occupied and can access other synchronized code blocks//Thread.Sleep (2000);
This.wait ();
Number *= 200;
System.out.println ("***second end**" + number+ "" +thread.currentthread (). GetName ());
@Override public void Run () {try { FirstMethod ();
catch (Exception e) {e.printstacktrace (); } public static void Main (string[] args) throws Exception {Thread.CurrentThread (). SetName ("Test_wait_thr
EAD ");
Waittest threadtest = new Waittest ();
Thread thread = new Thread (threadtest);
Thread.Start ();
Threadtest.secondmethod (); }
}
2, quartz Implementation plan:
The regular thread judges that there are idle threads in the job thread pool and uses the idle thread to perform the job that will be performed (depending on the next execution time and priority two dimensions to determine which job will be executed first).
Missfire the thread to determine whether there is a miss trigger, depending on the set Miss policy, whether to discard or immediately execute the job