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
Q55: The _ method is called by a
Q56: Examine the SharedData class shown below. Suppose
Q57: Examine the SharedData class shown below. Suppose
Q58: Examine the SharedData class shown below. Suppose
Q58: If a thread sleeps after acquiring a
Q60: Which phrase best describes the purpose of
Q61: Consider an old fashioned telephone booth that
Q62: Assume three threads share a BankAccount object
Q64: Stale data occurs in multi-CPU machines when
Q68: What happens when a thread calls the
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents