Threads Flashcards

1
Q

Which Thread method enables a thread to wait on another thread before continuing its work?

A

join

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

Which Thread method executes the run method on a child thread?

A

start

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

Which term describes how responsive an application is during execution?

A

Liveness

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

Liveness

A

A concurrent application’s ability to execute in a timely manner is known as its liveness.

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

What types of problems can effect an applications liveness?

A

deadlock, starvation, livelock

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

Which term occurs when one or more threads access a shared resource so frequently that other threads are unable to gain needed access?

A

starvation

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

Which term describes controlled thread access to a shared resource, so as to reduce the likelihood of memory consistency errors between threads?

A

Synchronization

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

What is the effect of invoking the start method more than once on the same thread?

A

An IllegalThreadStateException is thrown.

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

Which term describes actions that are indivisible and cannot be stopped prematurely before they complete?

A

Atomicity

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

Which Thread attribute is used to control the relative likelihood and frequency that a thread will be given a time slice to execute?

A

priority

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

What is the Thread priority range?

A

1-10

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

Which term occurs when two or more threads are blocked forever while waiting for access to the same resource and are unable to complete their tasks?

A

Deadlock

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

Which keyword declares a method, block, or code that is limited to a single concurrent thread?

A

synchronized

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

Which term occurs when two or more threads are too busy responding to each other to complete their tasks?

A

livelock

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

Which Thread attribute is used to control whether the JVM may exit before the thread terminates?

A

daemon

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

What does the Thread.yield() method do

A

It provides a hint to the scheduler that the current thread is willing to yield its current use of a processor. The scheduler is free to ignore this hint.

17
Q
Given:
Executor ex = Executors.newScheduledThreadPool(5);
How many threads will be created when passing tasks to the Executor object?
A

Five threads will be created; each thread supporting a single task.

18
Q

Explain the Executors method:

newSingleThreadExecutor

A

Creates an Executor that uses a single worker thread operating off an unbounded queue. The returned executor is guaranteed not to be reconfigurable to use additional threads.

19
Q

Explain the Executors method:

newCachedThreadPool

A

Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available.

20
Q

Explain the Executors method:

newFixedThreadPool

A

Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. Number of fixed threads must be specified.

21
Q

Explain the Executors method:

newScheduledThreadPool

A

Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically. Mujst specify the number of threads to keep in the pool even if they are idle.

22
Q

what does getRawResult return for a RecursiveAction object.

A

null