Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 7: ArrayList
Start Practice TestPractice Test
About Exam
hard Solved by 1 students

Concurrent ArrayList Modification

Mark
< Prev
Next >

Consider the following code. What is the most likely issue to arise when multiple threads concurrently modify the unsynchronized ArrayList?

import java.util.ArrayList;

public class EndlessAdd {
    static ArrayList<Integer> list = new ArrayList<>();
    public static void main(String[] args) {
        for (int i = 0; i < 50; i++) {
            new Thread(() -> {
                for (int j = 0; j < 1000; j++) {
                    list.add(j);
                }
            }).start();
        }
    }
}
A

Race conditions leading to data corruption and unpredictable list state

B

ConcurrentModificationException triggered by bulk additions

C

OutOfMemoryError due to rapid, unbounded growth of the ArrayList

D

Deadlock due to too many threads acquiring locks simultaneously

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|