Exam 20: Multithreading

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Suppose thread one is downloading a 800KB file while another thread is processing the same file on a single CPU machine. Suppose further that one time slice allows the first thread to download about 10KB and that the second thread can process 10KB of the file in one time slice. How many total time slices will it take to process half the file?

(Multiple Choice)
4.8/5
(39)

Stale data occurs in multi-CPU machines when one thread modifies shared data and a second thread accesses that data later, but sees the data value before the change took place. What is required to guarantee that the second thread sees the updated data, not stale data?

(Multiple Choice)
4.9/5
(37)

Which argument(s) present(s) the best case(s) for extending the Thread class rather than using the Runnable interface in conjunction with a thread pool? I Thread sub-classes will all execute independently II Runnable objects will waste more system resources III Thread sub-classes can execute faster on a single CPU than Runnable objects

(Multiple Choice)
4.9/5
(37)

Which method(s) are part of the Thread class? I public void run(Runnable runnable) II public void start(Runnable runnable) III public void start()

(Multiple Choice)
4.8/5
(38)

Examine the SharedData class shown below. Suppose two threads are created so that each has access to the same SharedData object. Thread one calls setSharedData eight times with values 1...8 respectively, sleeping for 30 milliseconds between calls. Thread two calls getSharedData eight times, also sleeping for 30 milliseconds between calls. Suppose thread two receives values 1, 2, 3, 4, 5, 6, 7, 8 respectively on its calls. Should we expect the same values for each program run? Public class SharedData { Private int value; Public void setSharedData(int n) { Value = n; } Public int getSharedData() { Return value; } }

(Multiple Choice)
5.0/5
(36)

If a thread sleeps after acquiring a _________, it blocks all other threads that want to acquire it.

(Multiple Choice)
4.7/5
(40)

Suppose thread one is downloading a 800KB file while another thread is processing the same file on a single CPU machine. Suppose further that one time slice allows the first thread to download about 10KB and that the second thread can process 10KB of the file in one time slice. Approximately how does the time to complete the entire job compare to having a single thread do the work?

(Multiple Choice)
4.9/5
(43)

Which of the following statements is correct?

(Multiple Choice)
4.8/5
(30)

Which of the following definitely indicates that a thread has been interrupted by another thread? I The run method has completed II The method Thread.interrupted returns true III The run method catches an InterruptedException

(Multiple Choice)
4.7/5
(43)

Which of the following scenarios may not always cause a deadlock among two threads? I Thread one is in an infinite loop and has acquired a lock II Both threads are in an infinite loop, and one thread has acquired a lock III Both threads are in an infinite loop, and both threads have acquired locks

(Multiple Choice)
4.9/5
(26)

Suppose thread one is downloading a 800KB file while another thread is processing the same file on a single CPU machine. Suppose further that one time slice allows the first thread to download about 10KB and that the second thread can process 10KB of the file in one time slice. How many total time slices will it take to see the first 10KB of the processed file?

(Multiple Choice)
4.9/5
(32)

When is it a good idea to call notifyAll in a synchronized method?

(Multiple Choice)
4.8/5
(34)

What happens when a thread calls the signalAll method of a Condition object connected to a lock, if no other thread had called await on that Condition object?

(Multiple Choice)
4.7/5
(46)

In the initial release of the Java library, the Thread class had a stop method to terminate a thread. However, that method is now _______________

(Multiple Choice)
4.8/5
(49)

What happens if we try to start a thread with an instance of a Runnable class that did not override the run method?

(Multiple Choice)
5.0/5
(30)

The ____ method is useful only if you know that a waiting thread can actually proceed.

(Multiple Choice)
4.7/5
(36)

Which of the following does not create an object that can run in a thread, assuming the following MyRunnable class declaration? Public class MyRunnable implements Runnable { . . . } I Runnable runnable = new Runnable(); II Runnable runnable = new MyRunnable(); III MyRunnable runnable = new MyRunnable();

(Multiple Choice)
4.9/5
(34)

Given a two-CPU machine and four threads, how many of the threads can execute in parallel?

(Multiple Choice)
4.8/5
(33)

To start a thread, you should first construct an object from a class that implements the ____________ interface.

(Multiple Choice)
4.8/5
(34)

What is the relationship between synchronized code and code that is locked using a ReentrantLock object?

(Multiple Choice)
4.9/5
(25)
Showing 61 - 80 of 82
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)