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.Suppose thread two receives values 1, 2, 3, 4, 5, 6, 7, 8 respectively on its calls.Should we expect the same values for each program run?
A) Yes, because the sleep times are equal in between calls.
B) Yes, because that's the same order used by thread one to set the values.
C) No, because thread one may not set the data as 1,2,3,4,5,6,7,8 respectively.
D) No, because a race condition may result in a
Correct Answer:
Verified
Q54: Assume two threads share a BankAccount object
Q55: The _ method is called by a
Q56: Consider the addFirst method of the LinkedList
Q57: Which of the following statements is correct?
A)If
Q58: If a thread sleeps after acquiring a
Q60: Which phrase best describes the purpose of
Q61: Consider an old fashioned telephone booth that
Q62: A GUI should be responsive to the
Q63: Calling the wait method in synchronized code
Q64: Which are ways that a thread can
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