Which of the three are valid modifications to synchronize access to the valid list between threads t1 and t2?

Given: Which of the three are valid modifications to synchronize access to the valid list
between threads t1 and t2?

Given: Which of the three are valid modifications to synchronize access to the valid list
between threads t1 and t2?

A.
Replace line 6 with: synchronized (bar) {for (int i= 0; i<5000; i++) WorkPool.addItem(); }
korrekte Schreibweise: synchronized (bar) {for (int i= 0; i<500; i++) WorkPool.addItem(); }

B.
Replace line 1 with: Synchronized (t2) (t1.start();) synchronized(t1) (t2.start(); ) korrekte
Schreibweise: synchronized (t2) {t1.start();} synchronized(t1) { t2.start();}

C.
Replace Line 2 with: static CopyWriteArrayList<Integer> list = new

CopyWriteArrayList<>(); korrekte Schreibweise: static CopyOnWriteArrayList<Integer> list =
new CopyOnWriteArrayList<>();

D.
Replace line 3 with: synchronized public static void addItem () { korrekte Schreibweise:
synchronized public static void addItem () {

E.
Replace line 4 with: synchronized (list) (list.add(1);) korrekte Schreibweise: synchronized
(list) { (list.add(1); }

F.
Replace line 5 with: Synchronized public void run () { korrekte Schreibweise:
synchronized public void run () {

G.
replace line 6 with: Synchronized (this) {for (in i = 0, i<5000, i++) WorkPool.addItem(); }
korrekte Schreibweise: synchronized (this) {for (int i = 0; i<500; i++) WorkPool.addItem(); }



Leave a Reply 1

Your email address will not be published. Required fields are marked *