How can a background process that uses the ScheduledExecutorService
be invoked from a call to a servlet?
I need to pass in some parameters for runnable method as well.
I'm currently using the following code to start a executor.
executor = Executors.newSingleThreadScheduledExecutor();
executor.scheduleAtFixedRate(new RefreshTask(), 0, 1, TimeUnit.SECONDS);
What I need to know is,
- How I can start the method manually via a call to a servlet.
- How to pass in some parameters(a URL) to the
RefreshTask()
method
A similar question was asked here: https://stackoverflow.com/a/25245786/3156644 But it's not clear how I should go about injecting the resources or start the process.
Also, I'm using a Jetty embedded server for this project.