why should i use android service instead of java thread

后端 未结 7 2055
遥遥无期
遥遥无期 2021-02-02 12:56

I am confused with android services and java thread.

Please help me to understand in which scenario i should use them.

As per my understanding

相关标签:
7条回答
  • 2021-02-02 13:49

    Let me give an analogy.

    Activities and Service are like projects.

    Activities are like external projects. This is what the clients(users) see.

    Services are like internal projects. There might be several internal projects for 1 external project or none at all.

    You can "pause" external project but the internal project that supports it can still continue.

    Main Thread is like the boss in a company

    The boss should never be held up by too much work since he shouldn't be late to meetings (UI freezing) or the client(user) will be unhappy.

    Threads are like employees in a company.

    The more you have, the more things you can do at the same time provided you have enough equipment(CPU speed) for all of them.

    Multiple employees can work on the same project at the same time but the boss should really work only on the Activities.

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