异步任务和守护进程之间的区别
Differences between Asynctasks and Daemons
在这个问题中:Android: AsyncTask vs Service,有人回答了
Service is a daemon, AsynkTask is background thread
有人回复了这个答案:
A service is not a daemon as it doesn't have its own thread of execution.
问题:由于两者都使用线程操作并在后台工作,除了各自的生命周期之外,Asynctasks 和 Daemon[ 之间的主要区别是什么=21=] 进程?
根据: http://www.linux.org/threads/android-services-and-daemons.7143/
服务:
A "Service" is special software that runs in the background like a
daemon on GNU/Linux. Services doesn't have GUIs. A "started service"
runs in the background until it completes its task, crashes, or is
explicitly closed by the user or application. A "bound service"
persists until no more apps are attached or bound to the service.
AsyncTasks:
AsyncTasks are designed for once-off time-consuming tasks that cannot
be run of the UI thread. A common example is fetching/processing data
when a button is pressed.
守护进程:
A "daemon" is a process that runs in the background *without owning a GUI. Services are usually daemons, and daemons are typically considered services. However, the exact difference between services and daemons is blurred. In general, they can be considered the same entity. However, some people use “daemon” to refer to a piece of software and “service” to refer to the actions and APIs offered by a daemon.
我在任何地方都没有见过与服务或 AsyncTask 一起使用的守护进程。对我来说,守护线程是来自 java 的线程,它允许 JVM 完成甚至未完成的线程。就 Android 而言,您无法控制您的 App 进程 - 您最多可能会杀死它。
Android 服务是一个组件 - 这将它放在 Activity 组件附近。这是什么意思?它由系统管理——它有自己的生命周期,在此期间生命周期方法被调用。服务可以配置为重新创建,或者您可以将其设置为前台(这样系统将不太可能杀死它)。由于它是一个组件,您可以在单独的进程下将其配置为 运行。默认情况下它没有自己的执行线程 - 它 运行 在 UI 线程上。
现在 AsyncTask 是完全不同的东西,它不是一个组件,所以你不能从上面做任何事情。它有一个后台工作线程。实际上,AsyncTask 是 Exeuctors 线程池的包装器,带有一些生命周期方法——比如 onPreExecute、onPostExecute、...它不应该与服务相比较,而应该与 Loaders 相比较。
在这个问题中:Android: AsyncTask vs Service,有人回答了
Service is a daemon, AsynkTask is background thread
有人回复了这个答案:
A service is not a daemon as it doesn't have its own thread of execution.
问题:由于两者都使用线程操作并在后台工作,除了各自的生命周期之外,Asynctasks 和 Daemon[ 之间的主要区别是什么=21=] 进程?
根据: http://www.linux.org/threads/android-services-and-daemons.7143/
服务:
A "Service" is special software that runs in the background like a daemon on GNU/Linux. Services doesn't have GUIs. A "started service" runs in the background until it completes its task, crashes, or is explicitly closed by the user or application. A "bound service" persists until no more apps are attached or bound to the service.
AsyncTasks:
AsyncTasks are designed for once-off time-consuming tasks that cannot be run of the UI thread. A common example is fetching/processing data when a button is pressed.
守护进程:
A "daemon" is a process that runs in the background *without owning a GUI. Services are usually daemons, and daemons are typically considered services. However, the exact difference between services and daemons is blurred. In general, they can be considered the same entity. However, some people use “daemon” to refer to a piece of software and “service” to refer to the actions and APIs offered by a daemon.
我在任何地方都没有见过与服务或 AsyncTask 一起使用的守护进程。对我来说,守护线程是来自 java 的线程,它允许 JVM 完成甚至未完成的线程。就 Android 而言,您无法控制您的 App 进程 - 您最多可能会杀死它。
Android 服务是一个组件 - 这将它放在 Activity 组件附近。这是什么意思?它由系统管理——它有自己的生命周期,在此期间生命周期方法被调用。服务可以配置为重新创建,或者您可以将其设置为前台(这样系统将不太可能杀死它)。由于它是一个组件,您可以在单独的进程下将其配置为 运行。默认情况下它没有自己的执行线程 - 它 运行 在 UI 线程上。
现在 AsyncTask 是完全不同的东西,它不是一个组件,所以你不能从上面做任何事情。它有一个后台工作线程。实际上,AsyncTask 是 Exeuctors 线程池的包装器,带有一些生命周期方法——比如 onPreExecute、onPostExecute、...它不应该与服务相比较,而应该与 Loaders 相比较。