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
Q41: The thread that calls signalAll must own
Q42: The _ method is useful only if
Q43: a(n. _ object is used to control
Q53: Examine the SharedData class shown below. Suppose
Q56: Examine the SharedData class shown below. Suppose
Q57: Which of the following statements is correct?
A)If
Q60: Assume two threads share a BankAccount object
Q63: Assume two threads share a BankAccount object
Q72: Stale data occurs in multi-CPU machines when
Q74: Under what circumstances will a call to
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