#vulnerable code 
                             @Override
	public void run() {
		while (!halted.get()) {
			try {
				synchronized (sigLock) {
					while (paused && !halted.get()) {
						try {
							sigLock.wait(1000L);
						} catch (InterruptedException ignore) {
						}
					}
					if (halted.get()) {
						break;
					}
				}
				boolean noFireTime = false; // 没有下次执行时间，初始化为false
				long timeUntilTrigger = 1000;
				if (triggerObj != null) {
					triggerObj.updateAfterMisfire(null);
					long now = System.currentTimeMillis();
					Date nextFireTime = triggerObj.getNextFireTime();
					if (nextFireTime != null) {
						timeUntilTrigger = nextFireTime.getTime() - now;
					} else {
						noFireTime = true;
					}
				}

				while (!noFireTime && timeUntilTrigger > 2) {
					synchronized (sigLock) {
						if (halted.get()) {
							break;
						}
						if (triggered) {
							break;
						}

						try {
							sigLock.wait(timeUntilTrigger);
						} catch (InterruptedException ignore) {
						}

						if (triggerObj != null) {
							long now = System.currentTimeMillis();
							Date nextFireTime = triggerObj.getNextFireTime();
							if (nextFireTime != null) {
								timeUntilTrigger = nextFireTime.getTime() - now;
							} else {
								noFireTime = true;
							}
						}
					}
				}
				boolean goAhead;
				// 触发执行只有两个条件：1.时间到了；2。点立即执行；
				synchronized (sigLock) {
					goAhead = !halted.get() && !paused;
					// 重置立即执行标志；
					if (triggered) {
						triggered = false;
					} else { // 非立即执行。即，执行时间到了，或者没有下次执行时间。
						goAhead = goAhead && !noFireTime;
						if (goAhead && triggerObj != null) { // 执行时间到了，更新执行时间；没有下次执行时间，不更新时间，并且不执行作业
							triggerObj.triggered(null);
						}
					}
				}
				if (goAhead) {
					job.execute();
				}

			} catch (RuntimeException e) {
				log.error(String.format(SaturnConstant.ERROR_LOG_FORMAT, job.getJobName(), e.getMessage()), e);
			}
		}

	} 
                            #location 64 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             @Override
	public void run() {
		while (!halted.get()) {
			try {
				synchronized (sigLock) {
					while (paused && !halted.get()) {
						try {
							sigLock.wait(1000L);
						} catch (InterruptedException ignore) {
						}
					}
					if (halted.get()) {
						break;
					}
				}
				boolean noFireTime = false; // 没有下次执行时间，初始化为false
				long timeUntilTrigger = 1000;
				if (triggerObj != null) {
					triggerObj.updateAfterMisfire(null);
					long now = System.currentTimeMillis();
					Date nextFireTime = triggerObj.getNextFireTime();
					if (nextFireTime != null) {
						timeUntilTrigger = nextFireTime.getTime() - now;
					} else {
						noFireTime = true;
					}
				}

				while (!noFireTime && timeUntilTrigger > 2) {
					synchronized (sigLock) {
						if (halted.get()) {
							break;
						}
						if (triggered) {
							break;
						}

						try {
							sigLock.wait(timeUntilTrigger);
						} catch (InterruptedException ignore) {
						}

						if (triggerObj != null) {
							long now = System.currentTimeMillis();
							Date nextFireTime = triggerObj.getNextFireTime();
							if (nextFireTime != null) {
								timeUntilTrigger = nextFireTime.getTime() - now;
							} else {
								noFireTime = true;
							}
						}
					}
				}
				boolean goAhead;
				// 触发执行只有两个条件：1.时间到了 2.点立即执行
				synchronized (sigLock) {
					goAhead = !halted.get() && !paused;
					// 重置立即执行标志；
					if (triggered) {
						triggered = false;
					} else if(goAhead){ // 非立即执行。即，执行时间到了，或者没有下次执行时间
						goAhead = goAhead && !noFireTime; // 有下次执行时间，即执行时间到了，才执行作业
						if (goAhead) { // 执行时间到了，更新执行时间
							if(triggerObj != null) {
								triggerObj.triggered(null);
							}
						} else { // 没有下次执行时间，则尝试睡一秒，防止不停的循环导致CPU使用率过高（如果cron不再改为周期性执行）
                            try {
                                sigLock.wait(1000L);
                            } catch (InterruptedException ignore) {
                            }
						}
					}
				}
				if (goAhead) {
					job.execute();
				}

			} catch (RuntimeException e) {
				log.error(String.format(SaturnConstant.ERROR_LOG_FORMAT, job.getJobName(), e.getMessage()), e);
			}
		}

	}