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
Q43: a(n. _ object is used to control
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
Q57: 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
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