Synchronized List/Map in Java if only one thread is writing to it
问题 The first thread is filling a collection continuously with objects. A second thread needs to iterate over these objects, but it will not change the collection. Currently I use Collection.synchronized for making it thread-safe, but is there a fast way to doing it? Update It's simple: The first thread (ui) continuously writes the mouse position to the ArrayList, as long as the mousebutton is pressed down. The second thread (render) draws a line based on the list. 回答1: Even if you synchronize