O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Follow these steps to implement the example:

  1. Create a class named MyScheduledTask parameterized by a generic type named V. It extends the FutureTask class and implements the RunnableScheduledFuture interface:
        public class MyScheduledTask<V> extends FutureTask<V>                                implements RunnableScheduledFuture<V> {
  1. Declare a privateRunnableScheduledFuture attribute named task:
        private RunnableScheduledFuture<V> task;
  1. Declare a privateScheduledThreadPoolExecutor class named executor:
        private ScheduledThreadPoolExecutor executor;
  1. Declare a private long attribute named period:
        private long period;
  1. Declare a private long attribute named startDate:
        private long startDate;
  1. Implement a constructor of the class. It receives ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required