Now in my application, tasks are launched immediately, using makeImmediateTrigger :

 SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory("quartz.properties"); sched = schedFact.getScheduler(); sched.start(); String jobName = generateJobDetailName(); JobDetail jobDetail = new JobDetail(jobName, GRP_Immediate, MyJob.class); jobDetail.getJobDataMap().put(MyJob.DATA, data); Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 0); trigger.setName(jobName + "_Simpletrigger"); sched.scheduleJob(jobDetail, trigger); 

I want to change the application so that no more than five tasks are executed at the same time, the rest are queued and started only after any of the five working threads are released. What is the best way to do this? I guess it can be done something like this:

 if (sched.getCurrentlyExecutingJobs().size() <= 5) { ... } else { ... } 

but what then need to write in the else block?

    0