Deck 26: Multithreading

ملء الشاشة (f)
exit full mode
سؤال
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.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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.
سؤال
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.
سؤال
A new thread begins its life cycle by transitioning to the __________ state.

A)runnable.
B)waiting.
C)terminated.
D)new.
سؤال
This class is used to help implement mutual exclusion.

A)MutEx.
B)Condition.
C)Lock.
D)Signal.
سؤال
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.
سؤال
The main method executes in the ________ thread of execution.

A)starting
B)main
C)local
D)None of the above.
سؤال
With timeslicing,each thread is given a limited amount of time,called a __________,to execute on a processor.

A)Quantum.
B)Processor burst.
C)Time allocation.
D)Scheduling interval.
سؤال
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.
سؤال
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.
سؤال
The ArrayBlockingQueue method ________ returns the number of elements currently in the ArrayBlockingQueue?

A)size.
B)length.
C)getSize.
D)getLength.
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
An ExecutorService object is created by calling a static method of which class?

A)Executor.
B)Executors.
C)ExecutorService.
D)Thread.
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
The Callable interface declares this method.

A)get.
B)call.
C)run.
D)execute.
سؤال
SwingWorker method ________ executes a long computation in a worker thread.

A)execute.
B)performCalculation.
C)doInBackground.
D)None of the above.
سؤال
The submit method,when passed a Callable,returns an object of this type.

A)Future.
B)Callable.
C)Runnable.
D)Executor.
سؤال
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.
سؤال
The ________ thread should be used to perform all tasks that manipulate GUI components,because they are not thread safe.

A)event-handling.
B)event-dispatch.
C)GUI-handling.
D)None of the above.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 26: Multithreading
1
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.
C
2
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.
D
3
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.
B
4
A new thread begins its life cycle by transitioning to the __________ state.

A)runnable.
B)waiting.
C)terminated.
D)new.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
5
This class is used to help implement mutual exclusion.

A)MutEx.
B)Condition.
C)Lock.
D)Signal.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
6
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
7
The main method executes in the ________ thread of execution.

A)starting
B)main
C)local
D)None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
8
With timeslicing,each thread is given a limited amount of time,called a __________,to execute on a processor.

A)Quantum.
B)Processor burst.
C)Time allocation.
D)Scheduling interval.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
10
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
11
The ArrayBlockingQueue method ________ returns the number of elements currently in the ArrayBlockingQueue?

A)size.
B)length.
C)getSize.
D)getLength.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
12
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
13
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
14
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
15
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
16
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
17
An ExecutorService object is created by calling a static method of which class?

A)Executor.
B)Executors.
C)ExecutorService.
D)Thread.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
18
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
19
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
20
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
21
The Callable interface declares this method.

A)get.
B)call.
C)run.
D)execute.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
22
SwingWorker method ________ executes a long computation in a worker thread.

A)execute.
B)performCalculation.
C)doInBackground.
D)None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
23
The submit method,when passed a Callable,returns an object of this type.

A)Future.
B)Callable.
C)Runnable.
D)Executor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
24
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
25
The ________ thread should be used to perform all tasks that manipulate GUI components,because they are not thread safe.

A)event-handling.
B)event-dispatch.
C)GUI-handling.
D)None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.