Multiple Choice
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
Correct Answer:
Verified
Q22: If a thread sleeps after acquiring a
Q28: Under what conditions are locks unnecessary for
Q29: Exactly when does a thread finish in
Q31: Given a single CPU and four threads,
Q33: Suppose thread one is downloading a 800KB
Q34: Stale data occurs in multi-CPU machines when
Q36: "Livelock" occurs when one thread runs continuously,
Q37: Examine the SharedData class shown below. Suppose
Q62: Each thread runs for a short amount
Q79: What is likely to be true when