0

I have some data in my Json. This data updates automatically every 20 seconds.

There is a field in that josn called power Values of power could be from int 1 to 600

I would like to create a class which would check the value of power every 20 seconds and alert the user using in app notification if the value of the power goes above or below a certain value.

What is the best way of achieving this ? Is there a library that can be used ?

Sam
  • 350
  • 5
  • 18

1 Answers1

0

There are many patterns you can use.

You can opt for using a library such a quartz: http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/

or you can create a chron job on your OS that would do what quartz does: http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/ (I'd go with quartz)

Or you can do it yourself: http://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html

Alexandre Santos
  • 8,170
  • 10
  • 42
  • 64