Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java -- What is the most efficient way to synchronize an ArrayList?

My program has an openGL rendering thread and a data modification thread. The rendering thread accesses the data in a gaggle of ArrayLists, while the data modification thread alters, removes, and adds objects to the ArrayLists. The threads update about 60 times per second, and the ArrayList manipuation is the program's bottleneck. I've tried synch blocks (super slow), CopyOnWriteArrayLists (quite slow), and creating buffer ArrayLists in the rendering thread (lesser of three evils). What's the 'best' way to get maximum efficiency out of concurrent ArrayLists?

like image 312
farm ostrich Avatar asked Oct 11 '22 04:10

farm ostrich


1 Answers

List<YourObject> syncList = Collections.synchronizedList(yourList);
like image 107
Marcos Vasconcelos Avatar answered Oct 15 '22 09:10

Marcos Vasconcelos