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 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;
}
}
A) 9, 10
B) 10, 9
C) 1, 2
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
Q24: What course of action should be followed
Q28: Under what conditions are locks unnecessary for
Q29: Exactly when does a thread finish in
Q35: a(n. _ object is used to control
Q47: For threads of equal priority, which is
Q54: _ allow a thread to temporarily release
Q67: The Runnable interface has a single method
Q79: What is likely to be true when