Check out example codes for "swing timer". It will help you in understanding the concepts better.

Code Example 1

int delay = 1000; //milliseconds
  ActionListener taskPerformer = new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
          //...Perform a task...
      }
  };
  new Timer(delay, taskPerformer).start();

Learn ReactJs, React Native from akashmittal.com