Oracle Java SE 8 Programmer II 1z0-809 Question # 28 Topic 3 Discussion

Oracle Java SE 8 Programmer II 1z0-809 Question # 28 Topic 3 Discussion

1z0-809 Exam Topic 3 Question 28 Discussion:
Question #: 28
Topic #: 3

Given:

1z0-809 Question 28

and the code fragment:

1z0-809 Question 28

The threads t1 and t2 execute asynchronously and possibly prints ABCA or AACB.

You have been asked to modify the code to make the threads execute synchronously and prints ABC.

Which modification meets the requirement?


A.

start the threads t1 and t2 within a synchronized block.


B.

Replace line n1 with:private synchronized int count = 0;


C.

Replace line n2 with:public synchronized void run () {


D.

Replace line n2 with:volatile int count = 0;


Get Premium 1z0-809 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.