Chapter  5

Multithreading and Synchronization

Chapter 1 introduced the concept of the main thread, or UI thread, in which most events are handled. Even though you are not prevented from executing all your code from within the main thread, your application typically uses more than one thread. As a matter of fact, several threads are created and run as part of your application even if you don’t create new threads yourself. For example, Eclipse’s DDMS perspective shows these threads when an application runs on an Android 3.1-based Galaxy Tab 10.1:

  • main
  • HeapWorker
  • GC (Garbage Collector)
  • Signal Catcher
  • JDWP (Java Debug Wire Protocol)
  • Compiler
  • Binder Thread #1
  • Binder Thread #2

So far, we’ve discussed only the first one in the list, the main thread, ...

Get Pro Android Apps Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.