Asynchronous work is the second component of background work, alongside persistent work. While both persistent and asynchronous work take place in the background, they are ultimately quite different.
Asynchronous work is that which:
- Takes place in the moment.
- Does not need to persist across app restarts or device reboots.
- Occurs off the main thread, or blocks the main thread.
This is in contrast to persistent work, which you may schedule for future execution and which remains scheduled through app restarts and device reboots. An example of asynchronous work may be sending an HTTP request off the main thread, returning its result only when it arrives.
Java and Kotlin
The way you handle asynchronous work depends on the overall app architecture you follow. If you are working with a Java Programming Language app, your needs are different than if you are working with Kotlin.
|Further reading||For a full overview of Coroutines, see the Coroutines guide.||See the Java Threads page for more information.|
For more information on persistent work, see the persistent work overview.