jeudi 28 avril 2016

Multiple services writing/reading

I have multiple services that need to write/read in my database, and they can try to write/read at the same time. Those services are long running services (for Bluetooth, GPS,...)

I have 2 questions:

  • if I use a protected database (with a singleton), only one service can write at the same time. If an another service try to write, the database is locked and the value is lost! How can I manage this problem? Can I put the value in a queue or something?

  • In one of my activities, I want to read the database in order to make a linearGraph. So if I start this activity, it want to read the database. But what happen if a service is already writing?

  • If I put all the services in the same process(different than the process for activities), and all in the main thread, what happen? If I understood, the instructions in a thread are executed one at time, so the services will never try to write at the same time?

Aucun commentaire:

Enregistrer un commentaire