简体   繁体   中英

Java Thread Pool Executor

I am doing a reminder application.

I have the jobs in the priority queue.

The sample job object is {job_id : 1001, epoch : 1514140200000} .

The task is to make the job execute in that epoch time.

I am planning to dequeue a job from the queue and assign a thread to it and schedule it to run in that epoch time. Is there a way to do it or is that the correct way to do?

If you want to do this via Java thread pools, see the ScheduledExecutorService: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html .

That has a nice sample, but basically you can schedule tasks to run at particular times or after a particular delay.

Libraries like Quartz (as someone notes) provide lots of other options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM