Android AsyncTask - avoid multiple instances running

前端 未结 7 1526
夕颜
夕颜 2020-12-25 15:36

I have AsyncTask that processes some background HTTP stuff. AsyncTask runs on schedule (Alarms/service) and sometime user executes it manually.

I process records fro

相关标签:
7条回答
  • 2020-12-25 16:02

    You can execute your AsyncTask's on an Executor using executeOnExecutor()

    To make sure that the threads are running in a serial fashion please use: SERIAL_EXECUTOR.

    Misc: How to use an Executor

    If several activities are accessing your DB why don't create a sort of gateway database helper and use the synchronized block to ensure only one thread has access to it at an instant

    0 讨论(0)
提交回复
热议问题