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
Q52: Consider the following change to the deposit
Q53: Assume two threads share a BankAccount object
Q54: Consider the addFirst method of the LinkedList
Q55: The _ method is called by a
Q56: Examine the SharedData class shown below. Suppose
Q58: If a thread sleeps after acquiring a
Q58: Examine the SharedData class shown below. Suppose
Q60: Examine the SharedData class shown below. Suppose
Q61: Consider an old fashioned telephone booth that
Q62: Assume three threads share a BankAccount object
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