Object Escape by List::sublist— Analysis of ConcurrentModificationException Caused by Guava Lists::partition object publication

Haoyuan Wang
Sep 3, 2018 · 3 min read

I recently worked a ConcurrentModificationException thrown from a private member of a Callable class. At first sight, there doesn’t seem to be shared objects among threads. The logic is, a list is portioned into smaller lists, then each sublist is passed into a Callable for concurrent operation. It seemed safe to me because each thread is modifying its own sublist thus there should not be ConcurrentModificationException. This is the pseudocode:

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade