Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 8 (1 point) Which of the following correctly creates a synchronized met

ID: 3741113 • Letter: Q

Question

Question 8 (1 point) Which of the following correctly creates a synchronized method public synchronized class Bla private int data; public void changeData(int x) ( data-x public class Bla private synchronized int data; public void changeData(int x) data-x public class Bla private int data; public synchronized void changeData(int x) datax O All of these have the same affect. Save Question 9 (1 point) If 2 threads both repeatedly try to increment a counter variable that is shared by the 2 threads, eventually the counter variable will become corrupted that is it will no longer correctly refilect all the operations done by both threads. O True O False

Explanation / Answer

ANSWER 8: Here option (C) will be correct because we know that synchronized keyword can be used only with methods and code blocks. These methods or blocks can be static or non-static both.

ANSWER 9: It is true.

ANSWER 10: Here option(C) will be correct because of the java.lang.Object.notifyAll() wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.This method should only be called by a thread that is the owner of this object's monitor.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote