android - Do separate processes share a main thread? - Stack Overflow

I have an Android app with a few components, each set to run in their own processes:The activitiesA co

I have an Android app with a few components, each set to run in their own processes:

  1. The activities
  2. A content provider
  3. Foreground service
  4. Accessibility service

I've noticed that heavy work being done in the main thread of the activities or content provider also blocks my services (at least the accessibility service). For example, the accessibility service stops receiving events from the system as I move through different apps. Granted I need to move that work off of the main/UI thread, but how is it affecting my services in separate processes? Do separate processes share a "main" thread?

I have an Android app with a few components, each set to run in their own processes:

  1. The activities
  2. A content provider
  3. Foreground service
  4. Accessibility service

I've noticed that heavy work being done in the main thread of the activities or content provider also blocks my services (at least the accessibility service). For example, the accessibility service stops receiving events from the system as I move through different apps. Granted I need to move that work off of the main/UI thread, but how is it affecting my services in separate processes? Do separate processes share a "main" thread?

Share Improve this question edited Nov 22, 2024 at 0:58 Flyview asked Nov 21, 2024 at 6:36 FlyviewFlyview 1,9591 gold badge29 silver badges51 bronze badges 1
  • As it is technically not possible that multiple processes have access to the same thread I think your actual question is if there is some synchronization between the main threads of different apps. Thus if one main thread can somehow block or slow down the main thread of other apps. – Robert Commented Nov 21, 2024 at 8:23
Add a comment  | 

1 Answer 1

Reset to default 2

Do separate processes share a "main" thread?

No. Threads are owned by a process in all *nix systems, including Android.

I've noticed that heavy work being done in the main thread of the activities or content provider also blocks my services (at least the accessibility service)

We have no information on how you came to this conclusion, or even the definition of "blocks my services".

how is it affecting my services in separate processes?

If nothing else, "heavy work" is going to take up CPU time. Your foreground UI process is going to be given the highest priority from a CPU utilization standpoint. So, it may be that the "heavy work" is not blocking your other processes, but it is starving them of CPU time.

Beyond that, if that "heavy work" is preventing you from updating the UI, it stands to reason that an AccessibilityService is not going to get information about UI updates, since there are no updates. However, that gets back to the "we have no information on how you came to this conclusion" aspect of your question, as I am having to take guesses as to what your actual symptoms are. If you need further assistance, I recommend that you ask a separate Stack Overflow question with a minimal, complete, and verifiable example.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742308908a4419496.html

相关推荐

  • android - Do separate processes share a main thread? - Stack Overflow

    I have an Android app with a few components, each set to run in their own processes:The activitiesA co

    17小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信