Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Background thread in Jetty

Hi,

On Sun, Jul 22, 2018 at 5:00 PM Alexander Farber
<alexander.farber@xxxxxxxxx> wrote:
> are you discussing the
>
> https://www.eclipse.org/jetty/javadoc/current/org/eclipse/jetty/util/thread/ScheduledExecutorScheduler.html ?

Yes.

> It is difficult to find a usage example, for example for running a task every hour...

The API is very similar to that of JDK's schedulers:

Scheduler scheduler = new ScheduledExecutorScheduler();
scheduler.start();

scheduler.schedule(() -> { ... }, 1, TimeUnit.HOURS);

If it needs to be recurring, you just call schedule() again from
within the task.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.


Back to the top