[英]Simple Java timer library
I have need for timer code in Java with these features: 我需要Java中的定时器代码具有以下功能:
Runnable
or something like it) to execute once after a specific delay (with second precision) 设置代码片段( Runnable
或类似代码)在特定延迟后执行一次(具有第二精度) java.util.Timer
) 使用线程池(所以没有java.util.Timer
) I've looked into using Quartz, but it appears to be simply too large. 我已经研究过使用Quartz,但它似乎太大了。
Is there a smallish library that does this? 是否有一个小型图书馆这样做? Or can I actually use Quartz? 或者我可以实际使用Quartz吗? Or how would I implement it myself, using ScheduledExecutor
? 或者我如何使用ScheduledExecutor
自己实现它?
I didn't quite ask this question but the only thing you seem to want that Java timers aren't giving is thread pooling, and while I never got around to using the answers I got they seem to address that 我没有完全问这个问题,但你似乎只想要Java定时器没有给出的是线程池,虽然我从来没有使用我得到的答案他们似乎解决了这个问题
Can I saturate a program with Timer objects? 我可以使用Timer对象使程序饱和吗?
Look at this post : Java Timer vs ExecutorService? 看看这篇文章: Java Timer vs ExecutorService?
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); public ScheduledFuture<V> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); public ScheduledFuture<V> scheduleWithFixedDelay( Runnable command, long initialDelay, long delay, TimeUnit unit);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.