大规模时间触发事件处理 [英] large scale time triggered event handling

查看:54
本文介绍了大规模时间触发事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大规模编程中的另一个问题:

Another question in large scale programming:

我有一个带有时间戳和目标文件名的作业队列.(对于每个时间戳,可能有多达 500 个目标文件要处理).所有 500 个目标文件的处理算法都相同.我想做:

I have a job queue with time stamps and target file name. (For each timestamp, there might be up to 500 target files to process). The processing algorithms are the same for all the 500 target files. I want to do:

  • 用Java编写程序
  • 每当到达时间戳时,立即触发所有 500 个作业
  • 在计算效率、cpu 使用率和可扩展性方面高效执行

我知道这样做的愚蠢方法,使用while循环,检查当前时间是否是作业队列中的时间戳....但是还有其他选择吗?我也在网上谷歌了一下,也有一些人说在Unix中使用cron命令.(是的,我的目标设置是在 Unix 中.)

I know stupid way to do it, using while loop, checking if current time is the timestamp in job queue.... But any other alternatives? I also google it online, and there are also some ppl saying using cron command in Unix. (Yes, my target setup is in Unix.)

我是这个大规模计算领域的新手,欢迎任何推荐或建议.

I am new to this large scale computing field, any recommendation or suggestion is welcomed.

推荐答案

使用批处理调度程序,例如 Quartz,如果您希望您的作业队列是持久的.

Use a batch scheduler such as Quartz, if you want your job queue to be persistent.

一个轻量级的替代方案是 java.util.concurrent 包中的 ScheduledThreadPoolExecutor,您可以使用 Executors 工厂类创建它.这允许您注册 Runnable 任务以在固定时间执行.

A lighter-weight alternative is ScheduledThreadPoolExecutor from the java.util.concurrent package, which you can create using the Executors factory class. This allows you to register Runnable tasks to be executed at a fixed time.

这篇关于大规模时间触发事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆