Quiz 3 Flashcards

1
Q

What two methods may Java threads be created by?

A
  1. Extending Thread class
  2. Implementing the Runnable interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the run() method? What does it implement?

A

What executes in a separate thread; Runnable

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

What is the parameter for creating a Thread object?

A

An object of a class that implements Runnable

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

What does invoking the start() method do?

A
  1. Allocates memory and initializes a new thread in the JVM
  2. Calls the run() method, causing the JVM to run the thread
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the join() method in Java do?

A

Waits for the thread to finish executing before another continues

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

What exception can the join() method in Java throw?

A

InterruptedException

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

What is the purpose of the Executor interface?

A

Organizing thread creation and omitting the need for explicitly creating Thread objects and invoking its start() method, as well as providing a mechanism for communication between concurrent tasks

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

What is the parameter for the execute() method?

A

A Runnable object

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

What model is the Executor framework based on?

A

producer-consumer

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

What is the purpose of the Callable interface?

A

To allow Java threads to return results

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

What does the submit() method in the Callable interface do?

A

Returns a result as a “Future object”

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

Which Java thread interface separates the creation of threads from the results they produce, rather than waiting for a thread to terminate before retrieving results, so the parent only waits for the results to become available?

A

Callable

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

What are some advantages of thread pools?

A
  • Faster to service a request since a new thread doesn’t have to be created
  • Allows the number of threads in the application(s) to be bound to the size of the pool, preventing infinite threads
  • Allows different strategies for running tasks since the tasks to be performed are separated from task creation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What process resources are shared amongst threads?

A
  • Address space
  • Global variables
  • Open files
  • Child processes
  • Pending alarms
  • Signals and signal handlers
  • Accounting information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are benefits of multithreaded programming?

A
  • Responsiveness
  • Resource sharing
  • Economy
  • Scalability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between a concurrent multicore system and a parallel one?

A

Concurrent allows more than one task to make progress, parallel can perform more than one task simultaneously

17
Q

What are some challenges with multithreaded programming?

A
  • Identifying tasks
  • Balance
  • Data splitting
  • Data dependency
  • Testing & debugging
18
Q

A formula that identifies potential performance gains from adding additional computing cores to an application that has both serial and parallel components

A

Amdhal’s law

19
Q

_____ parallelism focuses on distributing subsets of the same data across multiple computing cores and performing the same operations on each core

20
Q

_____ parallelism involves distributing not data, but tasks (threads) across multiple computing cores

21
Q

What’s the difference between user threads and kernel threads?

A

User threads are managed without kernel support, kernel threads are managed directly by the OS

22
Q

Model that maps many user-level threads to one kernel thread, entire process blocks if a thread makes a blocking system call

A

many to one

23
Q

Model that maps each user thread to a kernel thread, can run when a thread makes a blocking system call

A

one to one

24
Q

Model that multiplexes many user-level threads to a smaller or equal number of kernel threads that can run in parallel

A

many to many

25
Q

Model that is a variation of the many to many model, allows a user-level thread to be bound to a kernel thread

26
Q

Providers a programmer with an API for creating and managing threads

A

thread library