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. What is one reason why thread two may not receive 7 and 8 on its two final calls to getSharedData?
Public class SharedData
{
Private int value;
Public void setSharedData(int n)
{
Value = n;
}
Public int getSharedData()
{
Return value;
}
}
A) Thread one produced two 8's.
B) Thread two is getting longer time slices.
C) Thread one is getting longer time slices.
D) The race condition.
Correct Answer:

Verified
Correct Answer:
Verified
Q12: Class MyClass has a single ReentrantLock object,
Q13: Suppose run1 and run2 are objects of
Q25: Suppose thread one is downloading a large
Q26: The sleep method is terminated with a(n)
Q58: The _ interface is designed to encapsulate
Q66: Consider an old fashioned telephone booth that
Q70: If you do not use the Runnable
Q70: The _ method does not actually cause
Q73: Consider an old fashioned telephone booth that
Q74: A GUI should be responsive to the