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 ...

Get Mastering Concurrency Programming with Java 9 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.