Gaurav Singh
Gaurav Singh

Reputation: 307

ListenableScheduledFuture and ListeningScheduledExecutorService

I am creating an instance of ListeningScheduledExecutorService via following code

service = MoreExecutors.listeningDecorator(new ScheduledThreadPoolExecutor(corePoolSize));

as described in guava docs.

but when i call

Future future = service.schedule(callableObj, delay, TimeUnit.MILLISECONDS);

variable "future" is of type "ScheduledFuture" and not of type "ListenableScheduledTask".

Is there anything i am missing?

Upvotes: 0

Views: 966

Answers (1)

Jean Logeart
Jean Logeart

Reputation: 53829

The return type of schedule is ListenableScheduledFuture:

ListenableScheduledFuture<MyObj> lsf = 
    service.schedule(callableObj, delay, TimeUnit.MILLISECONDS);

Upvotes: 1

Related Questions