Exam 21: Multithreading

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

Which method do you call to make a thread ineligible to run on the CPU for a set number of milliseconds?

(Multiple Choice)
4.8/5
(31)

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.9/5
(43)

The ________ method stops the current thread for a given number of milliseconds.

(Multiple Choice)
4.7/5
(32)

What course of action should be followed when a thread has been interrupted?

(Multiple Choice)
4.7/5
(32)

Suppose thread one is downloading a large 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. What is the main benefit of using two threads rather than using a single thread to do both parts of the job?

(Multiple Choice)
4.7/5
(37)

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.8/5
(39)

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

(Multiple Choice)
4.9/5
(33)

Under what conditions are locks unnecessary for multi-threaded programs?

(Multiple Choice)
4.9/5
(39)

Exactly when does a thread finish in Java?

(Multiple Choice)
4.8/5
(25)

Each thread runs for a short amount of time, called a ____________________.

(Multiple Choice)
4.9/5
(34)

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

(Multiple Choice)
4.8/5
(36)

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 100 milliseconds between calls. Thread two calls getSharedData eight times, also sleeping for 100 milliseconds between calls. Which of the following could be the last two values received by thread two? public class SharedData { Private int value; Public void setSharedData(int n) { Value = n; } Public int getSharedData() { Return value; } }

(Multiple Choice)
4.9/5
(42)

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.8/5
(41)

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 when access to the shared data occurs in two different methods?

(Multiple Choice)
4.9/5
(45)

What is likely to be true when thread one is downloading a 1MB file while thread two is downloading another 1MB file?

(Multiple Choice)
4.9/5
(43)

"Livelock" occurs when one thread runs continuously, while another thread never does. Which of the following is sufficient to cause livelock? I Thread one is in an infinite loop II Thread one possesses a lock and does not unlock it, but thread two requires the lock III Thread one requires a lock, but thread two possesses the lock

(Multiple Choice)
4.7/5
(28)

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 ten times with values 1...10 respectively, sleeping for a random number of milliseconds between calls. Thread two calls getSharedData eight times, also sleeping for a random number of milliseconds between calls. Which of the following could be the last two values received by thread two? public class SharedData { Private int value; Public void setSharedData(int n) { Value = n; } Public int getSharedData() { Return value; } }

(Multiple Choice)
4.9/5
(42)

The ___________ method does not actually cause threads to terminate; it merely sets a Boolean field in the thread data structure.

(Multiple Choice)
4.8/5
(46)

When a thread is interrupted, the most common response is to terminate the ____________ method.

(Multiple Choice)
4.9/5
(30)

In which method are the tasks that are performed by a thread coded?

(Multiple Choice)
4.8/5
(25)
Showing 21 - 40 of 82
close modal

Filters

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