From the course: Concurrent Programming with Android: Threads, Workers, and Kotlin Coroutines
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Challenge: Run multiple background tasks with threads
From the course: Concurrent Programming with Android: Threads, Workers, and Kotlin Coroutines
Challenge: Run multiple background tasks with threads
(light music) - [Instructor] Now it's time to put what you've learned to work. In this challenge, I'm going to ask you to improve an application. Here's the starting version of the app. I'll run it on my device so we can see how it works initially. It's a dice rolling application. Right now, each time I touch the roll button, I get a set of five randomized values. The values are unpredictable, and they're being calculated on the fly by the application. Let's take a look at the code and see how it's working. The function roll the dice is being called each time I tap that button. There are two arrays. One with references to the image views in the layout and one with references to six different drawable files. The drawables are here. They're die one, die two, and so on. And they're vector drawables, XML files. The image views are declared in the layout. In that array, this is die zero, this is one, two, and so…
Contents
-
-
-
-
(Locked)
Define and run a Runnable object4m 40s
-
(Locked)
Delay execution of a Runnable object3m 42s
-
Manage background tasks with threads5m 22s
-
(Locked)
Send a message to the UI from a background thread6m 6s
-
(Locked)
Challenge: Run multiple background tasks with threads3m 28s
-
(Locked)
Solution: Run multiple background tasks with threads3m 40s
-
(Locked)
-
-
-
-