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 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;
}
}
A) Yes, because the sleep times are equal in between calls.
B) Yes, because that's the same order used by thread one to set the values.
C) No, because thread one may not set the data as 1,2,3,4,5,6,7,8 respectively.
D) No, because a race condition may result in a different order.
Correct Answer:

Verified
Correct Answer:
Verified
Q12: Class MyClass has a single ReentrantLock object,
Q35: a(n. _ object is used to control
Q41: What happens if we try to start
Q49: Class MyClass has two ReentrantLock objects, myLock1
Q73: Consider an old fashioned telephone booth that
Q74: Assume two threads share a BankAccount object
Q75: Suppose thread one is downloading a 800KB
Q78: Suppose thread one is downloading a 800KB
Q79: Suppose run1 and run2 are objects of
Q80: Suppose thread one is downloading a 800KB