0

For example the android's AsyncTask class has static final fields called AsyncTask.SERIAL_EXECUTOR and AsyncTask.THREAD_POOL_EXECUTOR.

Does this mean the field is created once per application or there is only ONE AsyncTask.SERIAL_EXECUTOR for the entire OS.

Ragz
  • 11
  • 2
  • Possible duplicate of [Using static variables in Android](http://stackoverflow.com/questions/2475978/using-static-variables-in-android) – Janki Gadhiya Jul 12 '16 at 04:47

2 Answers2

1

Like every static instance, they are scoped only to your process (if your app has multiple processes, it'll have multiple `AsyncTask.THREAD_POOL_EXECUTORs - one per process).

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
0

Info in developer site

SERIAL_EXECUTOR
An Executor that executes tasks one at a time in serial order.

THREAD_POOL_EXECUTOR
An Executor that can be used to execute tasks in parallel.

This serialization is global app-wide (process-wise). In this case tasks are stored in an unbounded queue that are passed to THREAD_POOL_EXECUTOR to be executed. The task can then be executed in any thread in the executor’s pool but SERIAL_EXECUTOR makes sure only one task is passed and executed at a time, not multiple.

link https://developer.android.com/reference/android/os/AsyncTask.html

Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98