How to Rest the server to have a background thread?

Good time of day.

There is a system: Rest server that does two functions: responds to requests of the mobile client to poll the microcontroller for recording the obtained data.

If the client program communicates in fulfillment of his requests, how to organize the process of work with the controller? You need a constant polling of the device with the specified interval (t).
July 8th 19 at 16:48
1 answer
July 8th 19 at 16:50
Option 1.
Periodically poll the controller (via the crown or via sleep, if you need more than once a minute) in a separate process, folding the results into a database, processing of the results necessary.
The client receives a result from the database.

Option 2.
The survey controller to the application client, the caching of result of poll for N seconds (in memory, on disk, in a database).

It all depends on the frequency of survey time per survey, and so on.
Went to know about crowns and came across Scheduling and its implementation in spring fraemwork. I think I found what I was looking for. - alene.Roberts commented on July 8th 19 at 16:53

Find more questions by tags RESTful APIJava