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
Q41: The thread that calls signalAll must own
Q42: The _ method is useful only if
Q43: a(n. _ object is used to control
Q50: A waiting thread is blocked until another
Q52: Examine the SharedData class shown below. Suppose
Q53: Examine the SharedData class shown below. Suppose
Q57: Which of the following statements is correct?
A)If
Q58: Examine the SharedData class shown below. Suppose
Q60: Assume two threads share a BankAccount object
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