Multiple Choice
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;
}
}
A) 8, 10
B) 10, 9
C) 10, 8
D) 8, 7
Correct Answer:

Verified
Correct Answer:
Verified
Q4: Which phrase best describes the purpose of
Q9: Which method do you call to make
Q20: The _ method stops the current thread
Q29: Exactly when does a thread finish in
Q33: When a sleeping thread is interrupted, a(n)
Q36: "Livelock" occurs when one thread runs continuously,
Q43: The Runnable interface includes which method(s)?<br>I public
Q47: For threads of equal priority, which is
Q48: Suppose that the class XYZ implements the
Q79: What is likely to be true when