Differences between submit, execute, schedule

Hi All,

I have a my own ScheduledTaskExecutor that extends ScheduledThreadPoolExecutor and I have some methods to schedule some tasks in order to run it at fixed period and this work without issues.

Now I have to force the execution of an already scheduled task when an event occurs (actually I'm forcing it via JMX, but this is not the point).

I have seen in the ScheduledThreadPoolExecutor documentation some useful methods:

- submit

- execute

- schedule

Well, the difference between submit and execute is the returned value, but what is the difference between submit(task) and schedule(task, 0, TimeUnit.MILLISECONDS) ?

Basically what I image is:

I have a queue (blocking queue) of tasks, and every task is scheduled with its own period. When I want, I should take this task, cancel its scheduled execution, execute it using execute/submit/schedule, and then re-schedule it for periodic execution.

Another issue...the task could be running when the event for one-shot execution occurs....how can i know if a task is running ? I can do it in my task class (setting its status to something like RUNNING) but I'm wondering if there is not a way to know the status using the (Scheduled)Future.

thanks a lot

Ste

[1293 byte] By [nichelea] at [2007-11-27 10:35:10]
# 1

Ok, checking the ScheduledThreadPoolExecutor soure code, those methods perform the same think...

I'm still looking for a way to know the task state....

nichelea at 2007-7-28 18:33:27 > top of Java-index,Core,Core APIs...