title: Running a background process with your java app
body: <p>So I have this map that has the name of an employee and their voucher amount, as its key and value. </p>
  
  <p>Now, I want a specific amount to be added to the values at the first day of every new month. </p>
  
  <p>I have a working code that does this, but i am looking for a way to make it better</p>
  
  <pre><code>import java.time.LocalDateTime;
  import java.util.Map;
  import java.util.Set;
  import java.util.TreeMap;
  
  public class VoucherManager {
      private static double newVoucher = 2500.00;
      private Map&lt;String, Double&gt; employeeVoucher = new TreeMap&lt;&gt;();
      private  LocalDateTime now = LocalDateTime.now();
  
      public static VoucherManager getInstance() {
          return new VoucherManager();
      }
      public void incrementVoucher() {
          employeeVoucher.put("Olatunji Oniyide", 200.00);
          employeeVoucher.put("Andrew Mbata", 500.00);
          employeeVoucher.put("Opeyemi Oniyide", 700.00);
  
          Set&lt;Map.Entry&lt;String, Double&gt;&gt; set = employeeVoucher.entrySet();
          int day = now.getDayOfMonth();
          if((day == 1) || (day == 2)) {
              for(Map.Entry&lt;String, Double&gt; map : set)
                 System.out.println(map.getKey() + ":" + (map.getValue() + newVoucher));
          } else {
              throw new AssertionError();
          }
      }
  
      public static void main(String[] args) {
          VoucherManager voucher = VoucherManager.getInstance();
          voucher.incrementVoucher();
      }
      }
  </code></pre>
  
  <p>When I change the current date on my system to the first day of a new month, it does the job correctly, else it doesn't. </p>
  
  <p>But this only happens when the user runs the code on the first day of the month or second. When the user runs the code on the 3rd or 4th day of the month, it throws an error. </p>
  
  <p>So I want to ask if there's a way to have my app create a background process which automatically just updates the values with the new figures, even when the app is not being used.</p>