Deck 22: Concurrency

Full screen (f)
exit full mode
Question
A new thread begins its life cycle by transitioning to the __________ state.

A) runnable.
B) waiting.
C) terminated.
D) new.
Use Space or
up arrow
down arrow
to flip the card.
Question
It’s recommended that you do not explicitly create and use Thread objects to implement concurrency, but rather use the ________ interface.

A) ExecutorService
B) Runnable
C) Concurrent
D) Executor
Question
Which of the following statements is false?

A) A runnable thread transitions to the blocked state when it attempts to perform a task that cannot be completed immediately and it must temporarily wait until that task completes.
B) When a thread issues an input/output request, the operating system blocks the thread from executing until that I/O request completes-at that point, the blocked thread transitions to the runnable state, so it can resume execution.
C) A blocked thread cannot use a processor, even if one is available.
D) Each of the above statements is true.
Question
Which of the following statements is false?

A) Most operating systems support XE "timeslicing" timeslicing, which enables threads of equal priority to share a processor.
B) Without timeslicing, each thread in a set of equal-priority threads runs to completion before other threads of equal priority get a chance to execute.
C) With timeslicing, even if a thread has not finished executing when its quantum expires, the processor is taken away from the thread and given to the next thread of equal priority, if one is available.
D) An operating system's thread scheduler determines which thread runs next.
Question
A runnable thread enters the ________ state (sometimes called the XE "thread states:dead" XE "dead state" dead state) when it successfully completes its task or otherwise terminates (perhaps due to an error).

A) extinct
B) defunct
C) terminated
D) aborted
Question
An ExecutorService object is created by calling a static method of which class?

A) Executor.
B) Executors.
C) ExecutorService.
D) Thread.
Question
Which of the following statements is false?

A) A runnable thread can enter the XE "timed waiting state" timed waiting state for a specified interval of time. It transitions back to the runnable state when that time interval expires or when the event it's waiting for occurs.
B) Timed waiting threads and waiting threads can use a processor, if one is available.
C) A runnable thread can transition to the timed waiting state if it provides an optional wait interval when it's waiting for another thread to perform a task. Such a thread returns to the runnable state when it's notified by another thread or when the timed interval expires-whichever comes first.
D) Another way to place a thread in the timed waiting state is to put a runnable thread to sleep-a sleeping thread remains in the timed waiting state for a designated period of time (called a sleep interval), after which it returns to the runnable state.
Question
Which of the following statements is false?

A) Thread scheduling is XE "platform dependency" platform independent.
B) One simple thread-scheduler implementation keeps the highest-priority thread running at all times and, if there's more than one highest-priority thread, ensures that all such threads execute for a quantum each in round-robin fashion.
C) The round-robin process for all highest-priority threads continues until all threads run to completion.
D) Most programmers who use Java multithreading will not be concerned with setting and adjusting thread priorities
Question
Which of the following is not true of ExecutorService?

A) It is a subinterface of Executor.
B) It is an object that can be run in a separate thread.
C) It declares method shutdown.
D) It manages a group of threads.
Question
When a __________ method or block is running on an object, the object is locked so no other such method can run on that object at the same time.

A) synchronized
B) shared
C) thread
D) writeable
Question
Which of the following statements is false?

A) In a multithreaded application, threads can be distributed across multiple processors (if available) so that multiple tasks execute in parallel and the application can operate more efficiently.
B) The JVM creates threads to run a program and for housekeeping tasks such as garbage collection.
C) Multithreading can increase performance only on multi-core systems.
D) The vast majority of programmers should use existing collection classes and interfaces from the concurrency APIs that manage synchronization for you.
Question
Which of the following statements is false?

A) Java makes concurrency available to you through the language and APIs.
B) Concurrency is a subset of parallelism.
C) Today's multi-core computers have multiple processors that can perform tasks in parallel.
D) Java programs can have multiple threads of execution, where each thread has its own method-call stack and program counter, allowing it to execute concurrently with other threads. This capability is called multithreading.
Question
Which of the following statements is false?

A) Thread synchronization is necessary only for shared mutable data, i.e., data that may change during its lifetime.
B) With shared immutable data that will not change, it's not possible for a thread to see old or incorrect values as a result of another thread's manipulation of that data.
C) When you share immutable data across threads, declare the corresponding data fields XE "Keywords: final" XE "final:keyword" final to indicate that the values of the variables will not change after they're initialized. This prevents accidental modification of the shared data, which could compromise thread safety.
D) Labeling object references as final indicates that the referenced object is immutable.
Question
With timeslicing, each thread is given a limited amount of time, called a __________, to execute on a processor.

A) quantum
B) burst
C) time allocation
D) scheduling interval
Question
Which of the following statements is false?

A) Every Java thread has a thread priority that helps determine the order in which threads are scheduled.
B) Each new thread inherits the priority of the thread that created it.
C) Informally, higher-priority threads are more important to a program and should be allocated processor time before lower-priority threads.
D) Thread priorities guarantee the order in which threads execute.
Question
When using Java's built-in monitors, every object has a(n) ________ or a(n) ________ that the monitor ensures is held by a maximum of only one thread at any time.

A) monitor lock, intrinsic lock
B) built-in lock, free lock
C) mutual exlcusion lock, synchronization lock
D) None of the above.
Question
Two tasks that are operating ________ are both making progress at once.

A) sequentially
B) concurrently
C) iteratively
D) recursively
Question
The main method executes in the ________ thread of execution.

A) starting
B) main
C) local
D) None of the above.
Question
Two tasks that are operating ________ are executing simultaneously.

A) concurrently
B) in parallel
C) sequentially
D) iteratively
Question
The preferred means of creating multithreaded Java applications is by implementing the ________ interface. An object of a class that implements this interface represents a task to perform.

A) Thread
B) Runner
C) Runnable
D) None of the above.
Question
This class is used to help implement mutual exclusion.

A) MutEx.
B) Condition.
C) Lock.
D) Signal.
Question
When a thread executing a synchronized statement (or method) completes or satisfies the condition on which another thread may be waiting, it can call Object method ________ or ________ to allow a waiting thread or all waiting threads to transition to the runnable state again.

A) notifyThread, notifyAllThreads
B) wakeUpThread, wakeUpAllThreads
C) notify, notifyAll
D) None of the above.
Question
In a producer/consumer relationship, when a consumer finds the buffer empty or finds that the previous data has already been read, the consumer should call __________.

A) lock
B) signal
C) sleep
D) await.
Question
Which of the following statements is false?

A) A common way to perform synchronization is to use Java's built-in monitors.
B) Every object has a monitor and a monitor lock (or intrinsic lock).
C) A monitor ensures that its object's monitor lock is held by a maximum of two threads at a time.
D) Monitors and monitor locks can be used to enforce mutual exclusion.
Question
Which of the following is true for a correct producer/consumer relationship with one producer, one consumer, and a 5-cell buffer?

A) The producer can produce when all cells are full.
B) The consumer can consume when all cells are full.
C) The consumer can consume when all cells are empty.
D) None of the above.
Question
When a thread obtains the monitor lock on an object, then determines that it cannot continue with its task on that object until some condition is satisfied, the thread can call Object method ________; this releases the monitor lock on the object, and transitions the thread waits to the waiting state.

A) waitForOtherThreads
B) stop
C) waitForCondition
D) wait
Question
Which of the following statements is false?

A) If several synchronized statements in different threads are trying to execute on an object at the same time, only one of them may be active on the object-all the other threads attempting to enter a synchronized statement on the same object are placed in the XE "blocked state" b XE "thread states:blocked" locked state.
B) When a synchronized statement finishes executing, the object's monitor lock is released and one of the blocked threads attempting to enter a synchronized statement can be allowed to acquire the lock to proceed.
C) Java also allows synchronized methods. Before executing, a synchronized instance method must acquire the lock on the object that's used to call the method.
D) Using a synchronized block to enforce mutual exclusion is an example of the design pattern known as the Java Exclusion Pattern.
Question
In a producer/consumer relationship, the ________ portion of an application generates data and stores it in a shared object, and the ________ portion of an application reads data from the shared object.

A) consumer, producer
B) producer, consumer
C) outputter, inputter
D) None of the above.
Question
The BlockingQueue interface declares which two methods for blocked adding and blocked removing of elements from a circular buffer?

A) put and take.
B) add and remove.
C) push and pop.
D) place and get.
Question
Which of the following statements is false?

A) If an operation requires the executing thread to XE "lock:hold" XE "hold a lock" hold a lock while the operation is performed, a thread must XE "lock:acquire" XE "acquire a lock" relase the lock before proceeding with the operation. Other threads attempting to perform an operation that requires the same lock will be blocked until the first thread XE "lock:release" XE "release a lock" releases the lock, at which point the blocked threads may attempt to acquire the lock and proceed with the operation.
B) To specify that a thread must hold a monitor lock to execute a block of code, the code should be placed in a synchronized statement.
C) Code in a synchronized statement is said to be guarded by the monitor lock; a thread must acquire the lock to execute the guarded statements.
D) The monitor allows only one thread at a time to execute statements within synchronized statements that lock on the same object, as only one thread at a time can hold the monitor lock. The synchronized statements are declared using the synchronized keyword.
Question
Which one of the following statements is true with regard to a producer/consumer relationship with one producer and one consumer?

A) A producer can never produce faster than the consumer is consuming.
B) A consumer can never consume faster than the producer is producing.
C) A producer can produce more items than a consumer consumes.
D) A consumer can consume more items than a producer produces.
Question
Task is a _______ class.

A) anonymous inner
B) composite
C) nested
D) generic
Question
The________ handles interactions with the application's controls, such as rendering controls or processing user actions like mouse clicks.

A) JavaFX event-handling
B) JavaFX application
C) JavaFX GUI-handling
D) None of the above.
Question
Overridden Task method _______ performs the Task's work.

A) call
B) work
C) processInBackground
D) doWorkInBackground
Question
If a thread calls __________, then every thread waiting for the object becomes eligible to acquire the lock.

A) signalEach
B) signalAll
C) signal
D) signalMethods
Question
You can simulate atomicity by ensuring that ________.

A) at least one thread carries out its operations on an object at a time
B) two threads carry out their operations on an object in parallel
C) only one thread carries out its operations on an object at a time
D) None of the above.
Question
Interface ExecutorService provides the ________ method, which returns control to its caller either when all tasks executing in the ExecutorService complete or when the specified timeout elapses.

A) waitForTermination
B) wait
C) awaitTermination
D) None of the above.
Question
Thread safety in JavaFX applications is achieved not by synchronizing thread actions, but by ensuring that programs manipulate the scene graph from only the JavaFX application thread. This technique is called ________.

A) thread restriction.
B) scene graph confinement.
C) thread confinement.
D) None of the above.
Question
In a producer/consumer relationship with a single cell of shared memory, which of the following is true?

A) The consumer must run first.
B) The producer must run first.
C) The producer must run first or the consumer will have to wait.
D) The consumer must run first or the producer will have to wait.
Question
The ArrayBlockingQueue method ________ returns the number of elements currently in the ArrayBlockingQueue?

A) size.
B) length.
C) getSize.
D) getLength.
Question
To obtain a parallel stream, simply invoke method ________ on an existing stream.

A) toParallel
B) toStream
C) parallel
D) toParallelStream
Question
Arrays static method ________ applies a BinaryOperator to the current and previous array elements and stores the result in the current element.

A) prefix
B) parallelSet
C) parallelApply
D) parallelPrefix
Question
Which of the following statements is false?

A) Java SE 8 introduces a new CompletableFuture class (package java.util.concurrent), which implements the Future interface and enables you to asynchronously execute Runnables that perform tasks or Suppliers that return values.
B) CompletableFuture static method supplyAsync asynchronously executes a Supplier task that returns a value.
C) CompletableFuture static method runAsync asynchronously executes a Runnable task that does not return a result.
D) CompletableFuture method get is a blocking method-it causes the calling thread to run until the asynchronous task completes and returns its results.
Question
Which of the following statements is false?

A) Task method updateProgress updates a Task's progress property, which represents the percentage completion.
B) Task method updateValue updates a Task's value property, which holds each intermediate value.
C) Task method isCancelled returns a boolean value indicating whether the Task has been cancelled.
D) All of the above are true.
Question
Java's concurrency APIs include the fork/join framework, which helps programmers parallelize algorithms. The fork/join framework particularly well suited to divide-and-conquer-style algorithms, like the ________ sort.

A) insertion sort
B) selection sort
C) merge sort
D) bubble sort
Question
NumberFormat static method ________ returns a NumberFormat that's used to format a number as a percentage.

A) percent
B) getPercentInstance
C) percentage
D) toPercent
Question
To determine the difference between two Instants, use class Duration's static method ________, which returns a Duration object containing the time difference.

A) difference
B) interval
C) between
D) span
Question
NumberFormat method ________ returns a String representation of its argument in the specified numeric format.

A) number
B) toNumeric
C) format
D) numeric
Question
Streams are easy to parallelize, enabling programs to benefit from enhanced performance on ________ systems.

A) uni-core
B) serial
C) multi-core
D) sequential
Question
Class Instant's static method ________ gets the current time.

A) currentTime
B) immediate
C) now
D) present
Question
The Callable interface (of package java.util.concurrent) declares a single method named call that allows a task to return a value.

A) call
B) execute
C) invoke
D) None of the above.
Question
Duration method ________ returns the Duration as a long value in milliseconds.

A) milliseconds
B) term
C) extent
D) toMillis
Question
ExecutorService method ________ executes a Callable passed in as its argument. Method submit returns an object of type Future (of package java.util.concurrent) that represents the future result of the executing Callable.

A) submit
B) execute
C) future
D) perform
Question
Arrays static method ________ fills an array with values produced by a generator function that receives an int and returns a value of type int, long or double.

A) parallelFill
B) parallelFillAll
C) generateAll
D) parallelSetAll
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/54
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 22: Concurrency
1
A new thread begins its life cycle by transitioning to the __________ state.

A) runnable.
B) waiting.
C) terminated.
D) new.
runnable.
2
It’s recommended that you do not explicitly create and use Thread objects to implement concurrency, but rather use the ________ interface.

A) ExecutorService
B) Runnable
C) Concurrent
D) Executor
Executor
3
Which of the following statements is false?

A) A runnable thread transitions to the blocked state when it attempts to perform a task that cannot be completed immediately and it must temporarily wait until that task completes.
B) When a thread issues an input/output request, the operating system blocks the thread from executing until that I/O request completes-at that point, the blocked thread transitions to the runnable state, so it can resume execution.
C) A blocked thread cannot use a processor, even if one is available.
D) Each of the above statements is true.
D
4
Which of the following statements is false?

A) Most operating systems support XE "timeslicing" timeslicing, which enables threads of equal priority to share a processor.
B) Without timeslicing, each thread in a set of equal-priority threads runs to completion before other threads of equal priority get a chance to execute.
C) With timeslicing, even if a thread has not finished executing when its quantum expires, the processor is taken away from the thread and given to the next thread of equal priority, if one is available.
D) An operating system's thread scheduler determines which thread runs next.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
5
A runnable thread enters the ________ state (sometimes called the XE "thread states:dead" XE "dead state" dead state) when it successfully completes its task or otherwise terminates (perhaps due to an error).

A) extinct
B) defunct
C) terminated
D) aborted
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
6
An ExecutorService object is created by calling a static method of which class?

A) Executor.
B) Executors.
C) ExecutorService.
D) Thread.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following statements is false?

A) A runnable thread can enter the XE "timed waiting state" timed waiting state for a specified interval of time. It transitions back to the runnable state when that time interval expires or when the event it's waiting for occurs.
B) Timed waiting threads and waiting threads can use a processor, if one is available.
C) A runnable thread can transition to the timed waiting state if it provides an optional wait interval when it's waiting for another thread to perform a task. Such a thread returns to the runnable state when it's notified by another thread or when the timed interval expires-whichever comes first.
D) Another way to place a thread in the timed waiting state is to put a runnable thread to sleep-a sleeping thread remains in the timed waiting state for a designated period of time (called a sleep interval), after which it returns to the runnable state.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements is false?

A) Thread scheduling is XE "platform dependency" platform independent.
B) One simple thread-scheduler implementation keeps the highest-priority thread running at all times and, if there's more than one highest-priority thread, ensures that all such threads execute for a quantum each in round-robin fashion.
C) The round-robin process for all highest-priority threads continues until all threads run to completion.
D) Most programmers who use Java multithreading will not be concerned with setting and adjusting thread priorities
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is not true of ExecutorService?

A) It is a subinterface of Executor.
B) It is an object that can be run in a separate thread.
C) It declares method shutdown.
D) It manages a group of threads.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
10
When a __________ method or block is running on an object, the object is locked so no other such method can run on that object at the same time.

A) synchronized
B) shared
C) thread
D) writeable
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following statements is false?

A) In a multithreaded application, threads can be distributed across multiple processors (if available) so that multiple tasks execute in parallel and the application can operate more efficiently.
B) The JVM creates threads to run a program and for housekeeping tasks such as garbage collection.
C) Multithreading can increase performance only on multi-core systems.
D) The vast majority of programmers should use existing collection classes and interfaces from the concurrency APIs that manage synchronization for you.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following statements is false?

A) Java makes concurrency available to you through the language and APIs.
B) Concurrency is a subset of parallelism.
C) Today's multi-core computers have multiple processors that can perform tasks in parallel.
D) Java programs can have multiple threads of execution, where each thread has its own method-call stack and program counter, allowing it to execute concurrently with other threads. This capability is called multithreading.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following statements is false?

A) Thread synchronization is necessary only for shared mutable data, i.e., data that may change during its lifetime.
B) With shared immutable data that will not change, it's not possible for a thread to see old or incorrect values as a result of another thread's manipulation of that data.
C) When you share immutable data across threads, declare the corresponding data fields XE "Keywords: final" XE "final:keyword" final to indicate that the values of the variables will not change after they're initialized. This prevents accidental modification of the shared data, which could compromise thread safety.
D) Labeling object references as final indicates that the referenced object is immutable.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
14
With timeslicing, each thread is given a limited amount of time, called a __________, to execute on a processor.

A) quantum
B) burst
C) time allocation
D) scheduling interval
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following statements is false?

A) Every Java thread has a thread priority that helps determine the order in which threads are scheduled.
B) Each new thread inherits the priority of the thread that created it.
C) Informally, higher-priority threads are more important to a program and should be allocated processor time before lower-priority threads.
D) Thread priorities guarantee the order in which threads execute.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
16
When using Java's built-in monitors, every object has a(n) ________ or a(n) ________ that the monitor ensures is held by a maximum of only one thread at any time.

A) monitor lock, intrinsic lock
B) built-in lock, free lock
C) mutual exlcusion lock, synchronization lock
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
17
Two tasks that are operating ________ are both making progress at once.

A) sequentially
B) concurrently
C) iteratively
D) recursively
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
18
The main method executes in the ________ thread of execution.

A) starting
B) main
C) local
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
19
Two tasks that are operating ________ are executing simultaneously.

A) concurrently
B) in parallel
C) sequentially
D) iteratively
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
20
The preferred means of creating multithreaded Java applications is by implementing the ________ interface. An object of a class that implements this interface represents a task to perform.

A) Thread
B) Runner
C) Runnable
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
21
This class is used to help implement mutual exclusion.

A) MutEx.
B) Condition.
C) Lock.
D) Signal.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
22
When a thread executing a synchronized statement (or method) completes or satisfies the condition on which another thread may be waiting, it can call Object method ________ or ________ to allow a waiting thread or all waiting threads to transition to the runnable state again.

A) notifyThread, notifyAllThreads
B) wakeUpThread, wakeUpAllThreads
C) notify, notifyAll
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
23
In a producer/consumer relationship, when a consumer finds the buffer empty or finds that the previous data has already been read, the consumer should call __________.

A) lock
B) signal
C) sleep
D) await.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following statements is false?

A) A common way to perform synchronization is to use Java's built-in monitors.
B) Every object has a monitor and a monitor lock (or intrinsic lock).
C) A monitor ensures that its object's monitor lock is held by a maximum of two threads at a time.
D) Monitors and monitor locks can be used to enforce mutual exclusion.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following is true for a correct producer/consumer relationship with one producer, one consumer, and a 5-cell buffer?

A) The producer can produce when all cells are full.
B) The consumer can consume when all cells are full.
C) The consumer can consume when all cells are empty.
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
26
When a thread obtains the monitor lock on an object, then determines that it cannot continue with its task on that object until some condition is satisfied, the thread can call Object method ________; this releases the monitor lock on the object, and transitions the thread waits to the waiting state.

A) waitForOtherThreads
B) stop
C) waitForCondition
D) wait
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following statements is false?

A) If several synchronized statements in different threads are trying to execute on an object at the same time, only one of them may be active on the object-all the other threads attempting to enter a synchronized statement on the same object are placed in the XE "blocked state" b XE "thread states:blocked" locked state.
B) When a synchronized statement finishes executing, the object's monitor lock is released and one of the blocked threads attempting to enter a synchronized statement can be allowed to acquire the lock to proceed.
C) Java also allows synchronized methods. Before executing, a synchronized instance method must acquire the lock on the object that's used to call the method.
D) Using a synchronized block to enforce mutual exclusion is an example of the design pattern known as the Java Exclusion Pattern.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
28
In a producer/consumer relationship, the ________ portion of an application generates data and stores it in a shared object, and the ________ portion of an application reads data from the shared object.

A) consumer, producer
B) producer, consumer
C) outputter, inputter
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
29
The BlockingQueue interface declares which two methods for blocked adding and blocked removing of elements from a circular buffer?

A) put and take.
B) add and remove.
C) push and pop.
D) place and get.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following statements is false?

A) If an operation requires the executing thread to XE "lock:hold" XE "hold a lock" hold a lock while the operation is performed, a thread must XE "lock:acquire" XE "acquire a lock" relase the lock before proceeding with the operation. Other threads attempting to perform an operation that requires the same lock will be blocked until the first thread XE "lock:release" XE "release a lock" releases the lock, at which point the blocked threads may attempt to acquire the lock and proceed with the operation.
B) To specify that a thread must hold a monitor lock to execute a block of code, the code should be placed in a synchronized statement.
C) Code in a synchronized statement is said to be guarded by the monitor lock; a thread must acquire the lock to execute the guarded statements.
D) The monitor allows only one thread at a time to execute statements within synchronized statements that lock on the same object, as only one thread at a time can hold the monitor lock. The synchronized statements are declared using the synchronized keyword.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
31
Which one of the following statements is true with regard to a producer/consumer relationship with one producer and one consumer?

A) A producer can never produce faster than the consumer is consuming.
B) A consumer can never consume faster than the producer is producing.
C) A producer can produce more items than a consumer consumes.
D) A consumer can consume more items than a producer produces.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
32
Task is a _______ class.

A) anonymous inner
B) composite
C) nested
D) generic
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
33
The________ handles interactions with the application's controls, such as rendering controls or processing user actions like mouse clicks.

A) JavaFX event-handling
B) JavaFX application
C) JavaFX GUI-handling
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
34
Overridden Task method _______ performs the Task's work.

A) call
B) work
C) processInBackground
D) doWorkInBackground
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
35
If a thread calls __________, then every thread waiting for the object becomes eligible to acquire the lock.

A) signalEach
B) signalAll
C) signal
D) signalMethods
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
36
You can simulate atomicity by ensuring that ________.

A) at least one thread carries out its operations on an object at a time
B) two threads carry out their operations on an object in parallel
C) only one thread carries out its operations on an object at a time
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
37
Interface ExecutorService provides the ________ method, which returns control to its caller either when all tasks executing in the ExecutorService complete or when the specified timeout elapses.

A) waitForTermination
B) wait
C) awaitTermination
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
38
Thread safety in JavaFX applications is achieved not by synchronizing thread actions, but by ensuring that programs manipulate the scene graph from only the JavaFX application thread. This technique is called ________.

A) thread restriction.
B) scene graph confinement.
C) thread confinement.
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
39
In a producer/consumer relationship with a single cell of shared memory, which of the following is true?

A) The consumer must run first.
B) The producer must run first.
C) The producer must run first or the consumer will have to wait.
D) The consumer must run first or the producer will have to wait.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
40
The ArrayBlockingQueue method ________ returns the number of elements currently in the ArrayBlockingQueue?

A) size.
B) length.
C) getSize.
D) getLength.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
41
To obtain a parallel stream, simply invoke method ________ on an existing stream.

A) toParallel
B) toStream
C) parallel
D) toParallelStream
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
42
Arrays static method ________ applies a BinaryOperator to the current and previous array elements and stores the result in the current element.

A) prefix
B) parallelSet
C) parallelApply
D) parallelPrefix
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following statements is false?

A) Java SE 8 introduces a new CompletableFuture class (package java.util.concurrent), which implements the Future interface and enables you to asynchronously execute Runnables that perform tasks or Suppliers that return values.
B) CompletableFuture static method supplyAsync asynchronously executes a Supplier task that returns a value.
C) CompletableFuture static method runAsync asynchronously executes a Runnable task that does not return a result.
D) CompletableFuture method get is a blocking method-it causes the calling thread to run until the asynchronous task completes and returns its results.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
44
Which of the following statements is false?

A) Task method updateProgress updates a Task's progress property, which represents the percentage completion.
B) Task method updateValue updates a Task's value property, which holds each intermediate value.
C) Task method isCancelled returns a boolean value indicating whether the Task has been cancelled.
D) All of the above are true.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
45
Java's concurrency APIs include the fork/join framework, which helps programmers parallelize algorithms. The fork/join framework particularly well suited to divide-and-conquer-style algorithms, like the ________ sort.

A) insertion sort
B) selection sort
C) merge sort
D) bubble sort
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
46
NumberFormat static method ________ returns a NumberFormat that's used to format a number as a percentage.

A) percent
B) getPercentInstance
C) percentage
D) toPercent
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
47
To determine the difference between two Instants, use class Duration's static method ________, which returns a Duration object containing the time difference.

A) difference
B) interval
C) between
D) span
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
48
NumberFormat method ________ returns a String representation of its argument in the specified numeric format.

A) number
B) toNumeric
C) format
D) numeric
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
49
Streams are easy to parallelize, enabling programs to benefit from enhanced performance on ________ systems.

A) uni-core
B) serial
C) multi-core
D) sequential
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
50
Class Instant's static method ________ gets the current time.

A) currentTime
B) immediate
C) now
D) present
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
51
The Callable interface (of package java.util.concurrent) declares a single method named call that allows a task to return a value.

A) call
B) execute
C) invoke
D) None of the above.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
52
Duration method ________ returns the Duration as a long value in milliseconds.

A) milliseconds
B) term
C) extent
D) toMillis
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
53
ExecutorService method ________ executes a Callable passed in as its argument. Method submit returns an object of type Future (of package java.util.concurrent) that represents the future result of the executing Callable.

A) submit
B) execute
C) future
D) perform
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
54
Arrays static method ________ fills an array with values produced by a generator function that receives an int and returns a value of type int, long or double.

A) parallelFill
B) parallelFillAll
C) generateAll
D) parallelSetAll
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 54 flashcards in this deck.