-1

I tried to set a function that adds interest to a balance on a timer. I have tried using the timerstack function and scheduled executor service.

This is the function. It works on its own manually. I would like to make it run every 3 minutes.

public void interest_rate() 
    {   double interest = 2 ;
        balance = balance * (1 + (interest/100));
}
mjcn17
  • 1
  • 1
  • It might be more efficient if you do all these at the same moment every time you fetch the value. – SOFe Mar 11 '16 at 14:09

1 Answers1

0

You can use java.util.Timer & java.util.TimerTask Api for scheduling tasks at repeated intervals along with initial delay time. Please check out the example for better understanding.

you can check out this Timer.scheduleAtFixedRate method api

Keerthivasan
  • 12,760
  • 2
  • 32
  • 53