O'Reilly logo

Mastering Concurrency Programming with Java 9 - 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

The basic reader

The basic reader will use a standard ScheduledThreadPoolExecutor class to execute the tasks periodically. We will execute a task per RSS source, and there will be one minute between the termination of one execution of a task and the commencement of the next execution. These concurrent tasks are implemented in the NewsTask class. It has three internal attributes to store the name of the RSS feed, its URL, and the NewsBuffer class to store the news:

public class NewsTask implements Runnable { 
  private String name; 
  private String url; 
  private NewsBuffer buffer; 
 
  public NewsTask (String name, String url, NewsBuffer buffer) { 
    this.name=name; 
    this.url=url; 
    this.buffer=buffer; 
  } 

The run() method of this Runnable object simply parses ...

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