質問

I have a requirement which updates the file contents from multiple operation which can occur at the same time.

I need to queue each request and the change the contents of the file for each request one by one.

I am using android broadcast receiver which receives the events for changing the file contents.

How can I queue this events and make changes to file one after the other request.

Please provide some suggestion or if possible please provide any links that I can refer.

役に立ちましたか?

解決 2

I have used executor with single thread. When event is received, we can post runnable to the executor. As the pool has 1 thead, these tasks will run in sequence.

他のヒント

I came, several time ago, across a class used by Android internally to serve the purpose you want to reach and which is now available through the Android Support Library.

It's called AtomicFile, it is documented here and you can find its implementation here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top