Given:
and the code fragment:
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?
start the threads t1 and t2 within a synchronized block.
Replace line n1 with:private synchronized int count = 0;
Replace line n2 with:public synchronized void run () {
Replace line n2 with:volatile int count = 0;
Submit