Sinopsis
Android devices are multiprocessor systems that can run multiple operations simultaneously, but it is up to each application to ensure that operations can be partitioned and executed concurrently to optimize application performance. If the application doesn’t enable partitioned operations but prefers to run everything as one long operation, it can exploit only one CPU, leading to suboptimal performance. Unpartitioned operations must run synchronously, whereas partitioned operations can run asynchronously. With asynchronous operations, the system can share the execution among multiple CPUs and therefore increase throughput.
An application with multiple independent tasks should be structured to utilize asynchronous execution. One approach is to split application execution into several processes, because those can run concurrently. However, every process allocates memory for its own substantial resources, so the execution of an application in multiple processes will use more memory than an application in one process. Furthermore, starting and communicating between processes is slow, and not an efficient way of achieving asynchronous execution. Multiple processes may still be a valid design, but that decision should be independent of performance. To achieve higher throughput and better performance, an application should utilize multiple threads within each process.
Content
- Android Components and the Need for Multiprocessing
- Multithreading in Java
- Threads on Android
- Thread Communication
- Interprocess Communication
- Memory Management
- Asynchronous Techniques
- Managing the Lifecycle of a Basic Thread
- HandlerThread: A High-Level Queueing Mechanism
- Control over Thread Execution Through the Executor Framewor
- Tying a Background Task to the UI Thread with AsyncTask
- Services
- IntentService
- Access Content Providers with AsyncQueryHandler
- Automatic Background Execution with Loaders
- Summary: Selecting an Asynchronous Technique
0 komentar:
Posting Komentar