INFO5126_Threading Flashcards

1
Q

_______ tend to be more expensive and slow because they involve ______-level operations

A
  1. Threads
  2. kernel
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

_______ run parallel on the system

A

Threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

_______ are lightweight and efficient with _______ overhead

A
  1. Coroutines
  2. minimal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

_______ allows the scheduling of work to run using scheduling windows.

A

Work Manager

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the main android thread referred to as?

A

UI Thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What interface can be used to declare a thread class?

A

Runnable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What class should your class inherit from to implement a thread?

A

Thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the 2 ways to create a thread in android?

A
  1. Class inherits from Thread
  2. Class implements Runnable interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What function do you implement/override for a thread?

A

run()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does currentThread() return?

A

Reference to the currently executing thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What function is used to get a thread’s name?

A

getName()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What should you never do with a worker thread?

A

Update user interface elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A coroutine is a _______ design pattern

A

Concurrency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A _______ keeps track of all your coroutines, and it can cancel all of the coroutines started in it.

A

CoroutineScope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A _______ models a cancellable workflow with multiple states and a life-cycle

A

Job

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the 3 types of dispatchers?

A
  1. Main
  2. IO
  3. Default
17
Q

What are the 2 ways to start a coroutine?

A
  1. launch
  2. async
18
Q

Which way do you launch a coroutine if you want a result?

A

async

19
Q

Which way of launching a coroutine is “fire and forget”?

A

launch

20
Q

What makes a function main-safe?

A

Doesn’t block UI updates

21
Q

What function is used to move a coroutine out of the main thread?

A

withContext()

22
Q

What keyword is used on a function to enforce that a function is called from within a coroutine?

A

suspend

23
Q

A cancelled scope _______ create more coroutines

A

cannot

24
Q

What is a Job?

A

Handle to a coroutine

25
Q

What permission is required to make network requests?

A

INTERNET

26
Q

What are the 3 types of work WorkManager handles?

A
  1. Immediate
  2. Long Running
  3. Deferrable
27
Q

What function is overridden for WorkManager?

A

doWork()

28
Q

What class is extended to define work for the WorkManager?

A

Worker

29
Q

What is the base class for specifying parameters for work that should be enqueued by the WorkManager?

A

WorkRequest