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 30 milliseconds between calls. Thread two calls getSharedData eight times, also sleeping for 30 milliseconds between calls. What is one reason why thread two may not receive 7 and 8 on its two final calls to getSharedData? public class SharedData
{
Private int value;
Public void setSharedData(int n)
{
Value = n;
}
Public int getSharedData()
{
Return value;
}
}
A) Thread one produced two 8's.
B) Thread two is getting longer time slices.
C) Thread one is getting longer time slices.
D) The race condition.
Correct Answer:

Verified
Correct Answer:
Verified
Q4: Which phrase best describes the purpose of
Q19: Which constructor can be used to create
Q40: Calling the wait method in synchronized code
Q60: Assume two threads share a BankAccount object
Q61: Assume two threads share a BankAccount object
Q62: A waiting thread is blocked until another
Q66: Consider an old fashioned telephone booth that
Q67: The Runnable interface has a single method
Q68: Assume three threads share a BankAccount object
Q73: Which of the following statements is correct?<br>A)If